Skip to content

Garbage-collect old images #78

Garbage-collect old images

Garbage-collect old images #78

Workflow file for this run

name: Garbage-collect old images
on:
schedule:
- cron: '27 2 * * 0'
workflow_dispatch:
jobs:
read_config:
name: Read configuration from build-matrix.json
runs-on: ubuntu-latest
outputs:
supported_tags_regex: ${{ steps.get_tags.outputs.supported_tags_regex }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- id: get_tags
run: |
echo "supported_tags_regex=^$(
< build-matrix.json \
jq -cr '
[
(.version[].rubyver[:2] | join("\\.")),
(.version[].extra | select(length > 0))
] | join("|")
'
)\$" >> $GITHUB_OUTPUT
gc_old_images:
name: GC old images
runs-on: ubuntu-latest
needs: read_config
permissions:
packages: write
strategy:
matrix:
pkg:
- govuk-ruby-base
- govuk-ruby-builder
steps:
- uses: actions/delete-package-versions@v5
name: GC untagged images except 10 most recent
with:
package-name: ${{ matrix.pkg }}
package-type: container
min-versions-to-keep: 10
delete-only-untagged-versions: 'true'
- uses: actions/delete-package-versions@v5
name: GC tagged images for no-longer-supported tags
with:
package-name: ${{ matrix.pkg }}
package-type: container
min-versions-to-keep: 10
ignore-versions: ${{ needs.read_config.outputs.supported_tags_regex }}