feat(ci): auto-pin publish workflows to freshly built runner image
build-image.yml now pushes a moving :latest tag alongside :<short-sha>, and a follow-up pin job (running in :latest) rewrites the image pin in all three publish-*.yml to the new sha and commits it back to master with FAPAT. Publish workflows keep immutable sha pins, kept current with no manual bump. No rebuild loop: the pin commit only touches workflow_call files. Root README image-flow section updated to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -46,10 +46,54 @@ jobs:
|
||||
|
||||
# --insecure: push target is the plain-HTTP Gitea registry.
|
||||
# Base image pull (docker.io) stays HTTPS — no --insecure-pull.
|
||||
# :latest is a convenience tag for internal CI (the pin job below
|
||||
# runs in it). Publish workflows stay pinned to the immutable sha.
|
||||
/kaniko/executor \
|
||||
--context dir:///tmp/src \
|
||||
--dockerfile /tmp/src/Dockerfile \
|
||||
--destination "${IMAGE}:${SHORT_SHA}" \
|
||||
--destination "${IMAGE}:latest" \
|
||||
--insecure
|
||||
|
||||
echo "Pushed ${IMAGE}:${SHORT_SHA}"
|
||||
echo "Pushed ${IMAGE}:${SHORT_SHA} and ${IMAGE}:latest"
|
||||
|
||||
pin:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
# Freshly built runner image: git + GNU sed baked in, and it has no
|
||||
# non-shell ENTRYPOINT, so it works as a job container as-is (unlike the
|
||||
# kaniko image above). Pulls :latest that the build job just pushed.
|
||||
image: pi5-16.local:3005/mikkeli/novoyuuparosk-wiki-runner:latest
|
||||
steps:
|
||||
- name: Repoint publish workflows at the new image tag
|
||||
env:
|
||||
# Full-access PAT — needs contents:write to push the pin commit.
|
||||
# github.token is read-only here; PKGRW_PAT is registry-only.
|
||||
FAPAT: ${{ secrets.FAPAT }}
|
||||
URL_TO_GITEA: ${{ vars.URL_TO_GITEA }}
|
||||
run: |
|
||||
set -eu
|
||||
HOST="${URL_TO_GITEA#http://}"
|
||||
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
|
||||
|
||||
git clone "http://mikkeli:${FAPAT}@${HOST}/mikkeli/novoyuuparosk-auto-wiki" repo
|
||||
cd repo
|
||||
|
||||
for f in .gitea/workflows/publish-songs.yml \
|
||||
.gitea/workflows/publish-ses.yml \
|
||||
.gitea/workflows/publish-tech.yml; do
|
||||
sed -i -E "s#(novoyuuparosk-wiki-runner:)[A-Za-z0-9._-]+#\1${SHORT_SHA}#" "$f"
|
||||
done
|
||||
|
||||
if git diff --quiet; then
|
||||
echo "Pins already at ${SHORT_SHA}; nothing to commit."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config user.email "actions@novoyuuparosk.org"
|
||||
git config user.name "wiki-runner image bot"
|
||||
git commit -am "build: pin runner image to ${SHORT_SHA}"
|
||||
# Pin commit only touches publish-*.yml (on: workflow_call) — triggers
|
||||
# nothing, so no rebuild loop. Fails loudly if master moved meanwhile.
|
||||
git push origin HEAD:master
|
||||
|
||||
Reference in New Issue
Block a user