container cleanup #2
Workflow file for this run
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
--- | |
# Remove old containers | |
name: container cleanup | |
on: workflow_dispatch | |
permissions: | |
contents: read | |
jobs: | |
get-matrix: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: get-matrix | |
id: get-matrix | |
run: | | |
# Disable SC2046: Quote this to prevent word splitting | |
# I can't quote this, just look at it | |
# shellcheck disable=SC2046 | |
echo matrix=$( yq --input-format yaml --output-format json '.services | keys[]' docker/compose.yaml | sed 's/"//g' | jq -Rs 'split("\n") | del(.[-1])' | jq -c ) >> "${GITHUB_OUTPUT}" | |
- name: Check | |
run: | | |
jq . <<< '${{ steps.get-matrix.outputs.matrix }}' | |
outputs: | |
matrix: ${{ steps.get-matrix.outputs.matrix }} | |
cleanup: | |
name: container_cleanup | |
runs-on: ubuntu-latest | |
needs: | |
- get-matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
dockerfile: ${{ fromJson(needs.get-matrix.outputs.matrix) }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
# We have to use my own fork of actions/delete-package-versions at the moment | |
# to have access to 'dry-run' and 'ignore-versions-include-tags' features | |
# We can switch to upstream whe following PRs get merged: | |
# - [dry-run](https://github.com/actions/delete-package-versions/pull/119/commits) | |
# - [tags](https://github.com/actions/delete-package-versions/pull/104 | |
- name: Delete old packages | |
uses: AtomicFS/delete-package-versions@main | |
continue-on-error: | |
true | |
# we have continue-on-error because when I make a fork of this repo to debug something, | |
# the Docker containers would not build because this step fails to fetch existing containers | |
# (in fresh fork there are none) | |
with: | |
package-name: firmware-action/${{ matrix.dockerfile }} | |
package-type: container | |
min-versions-to-keep: 5 | |
ignore-versions: '^(main|latest|v(\d+\.?)+)$' | |
# ignore: | |
# - main | |
# - latest | |
# - vX | |
# - vX.X | |
# - vX.X.X | |
dry-run: true | |
ignore-versions-include-tags: true |