Delete unused packages #7222
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: Delete unused packages | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */8 * * *' | |
jobs: | |
run: | |
strategy: | |
matrix: | |
package-name: [platform-plugin-dev, platform-plugin-dev-base] | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Delete untagged images of ${{ matrix.package-name }} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const response = await github.request("GET /${{ env.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 /${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { }); | |
console.log("status " + deleteResponse.status) | |
} | |
} | |
env: | |
OWNER: orgs/FriendsOfShopware # or orgs/<org name> | |
PACKAGE_NAME: ${{ matrix.package-name }} | |
PER_PAGE: 100 |