Clean up container images #14
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: Clean up container images | |
on: | |
workflow_dispatch: | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
- cron: '0 0 1 * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v6.4.1 | |
env: | |
PACKAGE_NAME: dashboard-opcua-client | |
PER_PAGE: 100 | |
with: | |
github-token: ${{ secrets.DELETE_PACKAGES_TOKEN }} | |
script: | | |
const response = await github.request("GET /orgs/${{ github.repository_owner }}/packages/container/${{ env.PACKAGE_NAME }}/versions", | |
{ per_page: ${{ env.PER_PAGE }} | |
}); | |
for(version of response.data) { | |
if (version.metadata.container.tags.length == 0) { | |
console.log("delete " + version.id) | |
const deleteResponse = await github.request("DELETE /orgs/${{ github.repository_owner }}/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); | |
console.log("status " + deleteResponse.status) | |
} | |
} |