Files
faunosteo/.gitea/workflows/release-images.yml
T
bchanot 981a66f33b ci: workflows kept as prepared material, marked never executed; script paths under scripts/
No runner, secret or registry exists on the forge; the three files map onto
the stages of pnpm check:all so a future runner calls the same scripts.
2026-10-13 01:19:15 +02:00

129 lines
6.4 KiB
YAML

# Production images, built in CI and identified by digest (D-R13, owner amendment of
# 2026-10-12): the VPS pulls them and never compiles. Manual only (workflow_dispatch), never
# on push: no publication or promotion of a production image without an explicit run and
# a validation. Nothing here deploys; DEPLOY.md "Image deploy by digest (prepared at R0, not
# yet applied)" is the runbook.
#
# Hardening (security audits of R0): the dispatch input is a typed choice re-validated in
# the shell through an environment variable (never interpolated into a script); the
# advisory gates (RustSec, npm) run in a job that holds no secret, and the image job runs no
# third-party code before its login (no npm install, only the pinned checkout); the registry
# token reaches the login step only, through env, into a per-job DOCKER_CONFIG under
# RUNNER_TEMP created fresh before the login and removed by a literal path; the images are
# built by a named ephemeral buildx builder (`--builder`, so a missing builder fails instead
# of falling back to the daemon's shared BuildKit and its cache mounts). The
# `if: github.ref` line keeps honest runs on main or develop: it is not a security boundary
# (whoever can push a branch can dispatch a copy of this file), push access and the token's
# scope are. The real isolation from pull-request jobs is a dedicated release runner label
# that never runs them (Step 27 operations). Known mutable references, to pin at Step 27:
# the buildkit engine image of the builder, the base images of the Dockerfiles.
#
# STATUS 2026-10-13: prepared, never executed. No runner, no registry and none of the
# secrets below exist on the forge yet; configuring them is the CI/CD step, not R0.
#
# Secrets expected on the forge: REGISTRY (host, e.g. the Gitea container registry of this
# forge), REGISTRY_USER, REGISTRY_TOKEN (write:package scope). Images are pushed as
# <registry>/<namespace>/faunosteo_app:<sha> and faunosteo_worker:<sha>; the digests are
# printed in the job summary and are what the VPS pins.
name: release-images
on:
workflow_dispatch:
inputs:
sheet_bundle:
description: 'SHEET_BUNDLE for the app image (none = production default, draft = preview)'
required: true
type: choice
options:
- none
- draft
default: none
concurrency:
group: release-images-${{ github.sha }}
cancel-in-progress: false
jobs:
# No secret here: this job runs third-party code (pnpm install for the audit, the
# builder image) and must never see the registry token.
gates:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
env:
SHEET_BUNDLE: ${{ inputs.sheet_bundle }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate the dispatch input (the shell trusts the env value only after this)
run: |
case "$SHEET_BUNDLE" in
none|draft) ;;
*) echo "refused SHEET_BUNDLE value" >&2; exit 1 ;;
esac
- name: RustSec advisories gate (release only; CI runs it nightly)
run: |
docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker
bash docker/rust-run.sh cargo deny check advisories
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: npm advisories gate for the application image (production dependencies)
run: |
corepack enable && corepack prepare --activate
pnpm install --frozen-lockfile
pnpm audit --prod --audit-level=high
images:
needs: gates
runs-on: ubuntu-latest
env:
SHEET_BUNDLE: ${{ inputs.sheet_bundle }}
REGISTRY: ${{ secrets.REGISTRY }}
NAMESPACE: ${{ github.repository_owner }}
GIT_SHA: ${{ github.sha }}
BUILDER: faunosteo_release_${{ github.run_id }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Re-validate the dispatch input in this job
run: |
case "$SHEET_BUNDLE" in
none|draft) ;;
*) echo "refused SHEET_BUNDLE value" >&2; exit 1 ;;
esac
- name: Fresh per-job Docker config (fails if the directory already exists)
run: |
mkdir -m 700 "$RUNNER_TEMP/faunosteo-release-docker"
echo "DOCKER_CONFIG=$RUNNER_TEMP/faunosteo-release-docker" >> "$GITHUB_ENV"
- name: Ephemeral builder with its own cache (named; every build names it explicitly)
run: docker buildx create --name "$BUILDER" --driver docker-container
- name: Registry login (token in this step's env only, never on the command line)
env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: printf '%s' "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
- name: Build and push the application image
run: |
image="$REGISTRY/$NAMESPACE/faunosteo_app:$GIT_SHA"
docker buildx build --builder "$BUILDER" --push --provenance=false \
--metadata-file "$RUNNER_TEMP/app-metadata.json" \
--build-arg "SHEET_BUNDLE=$SHEET_BUNDLE" -t "$image" .
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/app-metadata.json")"
[ -n "$digest" ] || { echo "no digest in the build metadata" >&2; exit 1; }
echo "app: faunosteo_app:$GIT_SHA@$digest" >> "$GITHUB_STEP_SUMMARY"
- name: Build and push the worker image
run: |
image="$REGISTRY/$NAMESPACE/faunosteo_worker:$GIT_SHA"
docker buildx build --builder "$BUILDER" --push --provenance=false \
--metadata-file "$RUNNER_TEMP/worker-metadata.json" \
-f crates/worker/Dockerfile -t "$image" .
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/worker-metadata.json")"
[ -n "$digest" ] || { echo "no digest in the build metadata" >&2; exit 1; }
echo "worker: faunosteo_worker:$GIT_SHA@$digest" >> "$GITHUB_STEP_SUMMARY"
- name: Logout, remove the builder and the per-job Docker config (literal path)
if: always()
run: |
rc=0
docker logout "$REGISTRY" || true
docker buildx rm "$BUILDER" || rc=$?
rm -rf -- "${RUNNER_TEMP:?}/faunosteo-release-docker"
exit "$rc"