Clean up old images #22
This file contains hidden or 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 old images | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * 0" | |
jobs: | |
clean: | |
runs-on: ubuntu-latest | |
name: Delete old images | |
permissions: | |
packages: write | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fetch multi-platform package version SHAs | |
id: multi-arch-digests | |
run: | | |
web=$(docker manifest inspect ghcr.io/accurate0/perth-transport-map-web | jq -r '.manifests.[] | .digest' | paste -s -d ' ' -) | |
api=$(docker manifest inspect ghcr.io/accurate0/perth-transport-map-api | jq -r '.manifests.[] | .digest' | paste -s -d ' ' -) | |
worker=$(docker manifest inspect ghcr.io/accurate0/perth-transport-map-worker | jq -r '.manifests.[] | .digest' | paste -s -d ' ' -) | |
echo "multi-arch-digests=$web,$api,$worker" >> $GITHUB_OUTPUT | |
- uses: snok/[email protected] | |
with: | |
account: user | |
token: ${{ secrets.GITHUB_TOKEN }} | |
image-names: "perth-transport-map-api perth-transport-map-worker perth-transport-map-web" | |
image-tags: "!latest" | |
keep-n-most-recent: 3 | |
cut-off: 3d | |
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }} |