This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
Remove untagged Docker images #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Remove untagged container images | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 3 * * 1" | |
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) | |
} | |
} |