Cleanup old Docker Images #127
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: Cleanup old Docker Images | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # every day | |
jobs: | |
clean: | |
runs-on: ubuntu-latest | |
name: Delete old images | |
permissions: | |
packages: write | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fetch multi-platform package version SHAs | |
id: multi-arch-digests | |
run: | | |
SHOWCASE_WEBSITE_PROD=$(docker manifest inspect ghcr.io/tangram-orchestre/showcase-website:production | jq -r '.manifests.[] | .digest' | paste -s -d ' ' -) | |
SHOWCASE_WEBSITE_STAGING=$(docker manifest inspect ghcr.io/tangram-orchestre/showcase-website:staging | jq -r '.manifests.[] | .digest' | paste -s -d ' ' -) | |
echo "multi-arch-digests=${SHOWCASE_WEBSITE_PROD},${SHOWCASE_WEBSITE_STAGING}" >> $GITHUB_OUTPUT | |
- uses: snok/container-retention-policy@v3.0.0 | |
with: | |
account: tangram-orchestre | |
token: ${{ secrets.GITHUB_TOKEN }} | |
image-names: "showcase-website" | |
image-tags: "!production !staging" | |
cut-off: 1d | |
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }} |