Skip to content

Remove untagged images #7

Remove untagged images

Remove untagged images #7

name: Remove untagged container images
on:
workflow_dispatch:
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: Delete 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) {
if (version.metadata.container.tags.length == 0 && version.name !== "latest" && version.name !== "preview") {
console.log("Delete " + version.id)
const deleteResponse = await github.request("DELETE /orgs/${{ github.repository_owner }}/packages/container/${{ matrix.image-name }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}