Retag Images #154
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: Retag Images | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' # Every Sunday at midnight | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/retag/images.yml' | |
| - '.github/workflows/retag.yml' | |
| - 'cmd/retagger/**' | |
| permissions: | |
| contents: read | |
| jobs: | |
| retag: | |
| permissions: | |
| packages: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| name: Checkout | |
| - uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | |
| name: Login to GHCR | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update docker | |
| run: sudo apt update && sudo apt install -y docker-ce | |
| - name: Setup containerd snapshotter | |
| run: | | |
| sudo mkdir -p /etc/docker | |
| test ! -f /etc/docker/daemon.json && echo '{}' | sudo tee /etc/docker/daemon.json | |
| tmp="$(mktemp)" | |
| jq '.features["containerd-snapshotter"] = true' /etc/docker/daemon.json | tee "${tmp}" | |
| sudo cp "${tmp}" /etc/docker/daemon.json | |
| jq '.debug = true' /etc/docker/daemon.json | tee "${tmp}" | |
| sudo cp "${tmp}" /etc/docker/daemon.json | |
| rm "${tmp}" | |
| sudo systemctl restart docker | |
| - name: docker info | |
| run: docker version; docker info | |
| - if: ${{ github.event_name == 'pull_request' }} | |
| name: Setup retag registry (pr) | |
| run: | | |
| set -ex -o pipefail | |
| docker run -d --rm --name registry -p 5000:5000 ghcr.io/project-dalec/dalec/mirror/dockerhub/library/registry:latest | |
| echo "RETAG_REGISTRY=localhost:5000" >> $GITHUB_ENV | |
| echo "RETAG_REGISTRY_USE_HTTP=true" >> $GITHUB_ENV | |
| - if: ${{ github.event_name != 'pull_request' }} | |
| name: Setup retag registry (non-pr) | |
| run: | | |
| set -ex -o pipefail | |
| repo="ghcr.io/${{ github.repository }}" | |
| repo="$(tr '[:upper:]' '[:lower:]' <<<"$repo")" | |
| echo "RETAG_REGISTRY=${repo}" >> $GITHUB_ENV | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Retag images | |
| run: | | |
| go run ./cmd/retagger .github/workflows/retag/images.yml | |
| - if: failure() | |
| name: daemon logs | |
| run: sudo journalctl -u docker |