fix(ci): publish on a dedicated runner label, immutable version tags
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m6s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Successful in 48s
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m6s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 9s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Successful in 48s
The review's blocker was real: runs-on: ubuntu-latest is the label pr-checker.yml uses, and the job needs a runner-wide Docker socket, so the only working configuration violated the trust boundary in the decision doc. The job now runs on a dedicated 'publish' label that only a second act_runner registration (docker_host: automount) may carry. Version tags are now immutable: before building, the registry v2 API is asked for manifests/<version> and 200 aborts the run. docker manifest inspect cannot do this job - the pinned Debian 20.10 client fails on OCI indexes for existing and missing tags alike (measured). Also: the smoke test requires a rendered body (10 kB floor) on top of the 2xx, .github/actionlint.yaml declares the custom label, and the actionlint hook passes that config explicitly because this repo keeps workflows in .gitea/workflows, where actionlint does not auto-discover it.
This commit is contained in:
1 parent
435be63ae0
commit
eebd6ca697
5 files changed
+109
-31
No files matched your search
@@ -25,7 +25,14 @@ env:
|
||||
jobs:
|
||||
publish:
|
||||
name: Build and push image
|
||||
runs-on: ubuntu-latest
|
||||
# Dedicated label, NOT ubuntu-latest: this job needs the host Docker
|
||||
# socket, and `docker_host` is a runner-wide setting. Sharing a label
|
||||
# with pr-checker.yml would hand PR code (from a branch) a root-
|
||||
# equivalent socket on the host that also runs Gitea and k3s.
|
||||
# Register a second act_runner with `--labels publish:docker://node:22-bookworm`
|
||||
# and `container.docker_host: automount` in its config, before the first
|
||||
# tag: an unmatched label leaves the job queued indefinitely.
|
||||
runs-on: publish
|
||||
# A hung build would hold the capacity-1 runner and, through it, every
|
||||
# other job on this server. Gitea's instance default is not a contract.
|
||||
timeout-minutes: 20
|
||||
@@ -107,6 +114,50 @@ jobs:
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
echo "Building ${version} from ${sha} (latest: ${latest})"
|
||||
|
||||
- name: Log in to the registry
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
# Missing secrets must fail loudly: an anonymous `docker push`
|
||||
# would answer 401 with a message most people misread as a
|
||||
# missing repository.
|
||||
[ -n "$REGISTRY_USERNAME" ] || { echo "::error::secret REGISTRY_USERNAME is empty"; exit 1; }
|
||||
[ -n "$REGISTRY_PASSWORD" ] || { echo "::error::secret REGISTRY_PASSWORD is empty"; exit 1; }
|
||||
printf '%s' "$REGISTRY_PASSWORD" \
|
||||
| docker login registry.noelsabia.dev -u "$REGISTRY_USERNAME" --password-stdin
|
||||
|
||||
- name: Refuse to overwrite a published version
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
# A version tag is immutable once published. Gitea can replay any
|
||||
# run, and `docker push` would silently replace :vX.Y.Z with a
|
||||
# rebuilt image, so the release would change content after the
|
||||
# fact. A missing tag (first attempt, or a run that failed before
|
||||
# pushing) is fine - nothing was published.
|
||||
#
|
||||
# Registry v2 API instead of `docker manifest inspect`: the
|
||||
# Debian 20.10 client fails that command on OCI indexes with
|
||||
# "unsupported manifest media type and no default available",
|
||||
# for existing and missing tags alike.
|
||||
url="https://registry.noelsabia.dev/v2/cv_website/nuxt/manifests/${VERSION}"
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' \
|
||||
-u "${REGISTRY_USERNAME}:${REGISTRY_PASSWORD}" \
|
||||
-H 'Accept: application/vnd.docker.distribution.manifest.v2+json' \
|
||||
-H 'Accept: application/vnd.oci.image.index.v1+json' \
|
||||
-H 'Accept: application/vnd.oci.image.manifest.v1+json' \
|
||||
"$url")
|
||||
echo "GET /v2/cv_website/nuxt/manifests/${VERSION}: HTTP ${code}"
|
||||
case "$code" in
|
||||
200) echo "::error::${VERSION} is already published and version tags are immutable - delete that tag in the registry deliberately to replace it"; exit 1 ;;
|
||||
404) echo "${VERSION} is not published yet - continuing" ;;
|
||||
401|403) echo "::error::registry rejected the credentials (HTTP ${code}) - check REGISTRY_USERNAME/REGISTRY_PASSWORD"; exit 1 ;;
|
||||
*) echo "::error::unexpected answer from the registry (HTTP ${code})"; exit 1 ;;
|
||||
esac
|
||||
|
||||
- name: Build image
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
@@ -128,41 +179,33 @@ jobs:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
# Start the real server inside the built image and require a 2xx
|
||||
# from /. Cheaper than publishing a broken release, and the only
|
||||
# step that proves the Nitro output actually runs. Done inside the
|
||||
# container because the app's port is not reachable from this job
|
||||
# container - the daemon publishes on the host, not here.
|
||||
# with a real SSR body, not an empty shell. Cheaper than
|
||||
# publishing a broken release, and the only step that proves the
|
||||
# Nitro output actually runs. Done inside the container because
|
||||
# the app's port is not reachable from this job container - the
|
||||
# daemon publishes on the host, not here.
|
||||
#
|
||||
# The size floor is deliberately loose: the rendered homepage was
|
||||
# 97 kB on 2026-10-24, so 10 kB catches "200 but nothing rendered"
|
||||
# without failing on a future copy change.
|
||||
docker run --rm "${IMAGE}:${VERSION}" sh -c '
|
||||
node .output/server/index.mjs &
|
||||
server=$!
|
||||
i=0
|
||||
while [ "$i" -lt 30 ]; do
|
||||
if node -e "fetch(\"http://127.0.0.1:3000/\").then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"; then
|
||||
echo "server answered 2xx after ${i}s"
|
||||
if out=$(node -e "fetch(\"http://127.0.0.1:3000/\").then(async r => { const body = await r.text(); if (!r.ok || body.length < 10000) process.exit(1); console.log(r.status + \" \" + body.length + \" bytes\") }).catch(() => process.exit(1))" 2>/dev/null); then
|
||||
echo "homepage rendered after ${i}s: HTTP ${out}"
|
||||
kill "$server"
|
||||
exit 0
|
||||
fi
|
||||
i=$((i + 1))
|
||||
sleep 1
|
||||
done
|
||||
echo "server did not answer 2xx within 30s"
|
||||
echo "no 2xx homepage with a rendered body within 30s"
|
||||
kill "$server"
|
||||
exit 1
|
||||
'
|
||||
|
||||
- name: Log in to the registry
|
||||
env:
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
# Missing secrets must fail loudly: an anonymous `docker push`
|
||||
# would answer 401 with a message most people misread as a
|
||||
# missing repository.
|
||||
[ -n "$REGISTRY_USERNAME" ] || { echo "::error::secret REGISTRY_USERNAME is empty"; exit 1; }
|
||||
[ -n "$REGISTRY_PASSWORD" ] || { echo "::error::secret REGISTRY_PASSWORD is empty"; exit 1; }
|
||||
printf '%s' "$REGISTRY_PASSWORD" \
|
||||
| docker login registry.noelsabia.dev -u "$REGISTRY_USERNAME" --password-stdin
|
||||
|
||||
- name: Tag latest
|
||||
if: steps.version.outputs.latest == 'true'
|
||||
env:
|
||||
|
||||
Reference in new issue
Block a user