Skip to content

Remove untagged images #19

Remove untagged images

Remove untagged images #19

name: Remove untagged images
on:
workflow_dispatch:
# schedule:
# - cron: "0 4 * * *" # Every day at 04:00
jobs:
remove-untagged:
runs-on: ubuntu-latest
strategy:
matrix:
image-name: [tna-python, tna-python-root, tna-python-django, tna-python-django-root, tna-python-dev]
env:
PER_PAGE: 100
steps:
- name: Remove untagged images
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.request("GET /orgs/${{ github.repository_owner }}/packages/container/${{ matrix.image-name }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
console.log("=====================")
console.log(version)
if (version.metadata.container.tags.length) {
console.log(`Tags: ${version.metadata.container.tags.join(", ")}`)
} else {
console.log(`Delete ${version.id} (${version.name})`)
const deleteResponse = await github.request("DELETE /orgs/${{ github.repository_owner }}/packages/container/${{ matrix.image-name }}/versions/" + version.id, { });
console.log(deleteResponse.status)
}
}