Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Remove untagged Docker images #1

Remove untagged Docker images

Remove untagged Docker images #1

Workflow file for this run

name: Remove untagged container images
on:
workflow_dispatch:
jobs:
remove-untagged:
runs-on: ubuntu-latest
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/${{ vars.DOCKER_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/${{ vars.DOCKER_IMAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}