fix(ci): harden the build and image workflows after review

Pass ref and repository values to run steps as environment instead of
interpolating them into the script (a tag name may contain shell
metacharacters). In the image workflow: refuse tags that are not
vMAJOR.MINOR.PATCH[-prerelease] before anything runs, purge exactly the
packages the prepare step added instead of autoremove and fail on any
package or /etc file difference from the base image, send the registry
write probe with an empty body, and remove the registry credential after
the push also when the build fails.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-24 21:10:20 +00:00
1 parent fe6d19dde5
commit 0bc8d19775
3 files changed
+60 -15

No files matched your search

+8 -3
View File
@@ -45,12 +45,17 @@ jobs:
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
REF: ${{ github.ref }}
# Passed as environment, never interpolated into the script: a tag name may
# contain shell metacharacters.
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
git clone "${{ github.server_url }}/${{ github.repository }}" .
git clone "$REPO_URL" .
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
# Make sure the tag object itself is present (not only the commit it points at).
if [ "${{ github.ref_type }}" = "tag" ]; then
git fetch origin "+refs/tags/${{ github.ref_name }}:refs/tags/${{ github.ref_name }}"
if [ "$REF_TYPE" = "tag" ]; then
git fetch origin "+refs/tags/${REF_NAME}:refs/tags/${REF_NAME}"
fi
echo "Checked out $(git rev-parse HEAD)"