Files
bcs-website/.gitea/workflows/ci.yml
T
bmr_bluecap 0f769d7bdd feat(contact): wire the form to a real endpoint at build time
The contact form could not be made to work by configuration. Two reasons,
both fixed here.

The endpoint never reached the browser. k8s/configmap.yaml carried
PUBLIC_CONTACT_FORM_ENDPOINT, but the Deployment has no env/envFrom pointing
at that ConfigMap, so it was dead config. Wiring it up would not have helped
either: this is a static Astro build, so import.meta.env.PUBLIC_* is inlined
when the image is built and the pod only serves pre-built HTML. Anything the
browser needs has to arrive as a build arg. Add ARG/ENV to the Dockerfile and
pass --build-arg from CI, sourced from a CONTACT_FORM_ENDPOINT Actions
secret. Rewrite the ConfigMap as documentation of what the build expects,
with an explicit warning not to add envFrom.

Submission behaviour was also wrong for visitors. A native POST would have
navigated them to the form provider's page; post in the background with
fetch() and send them to our own /thank-you/ instead. On failure the form now
stays put, re-enables the button and offers the phone and email fallback,
rather than silently losing the inquiry. Add a honeypot (_gotcha, which
Formspree treats as spam) positioned off-screen rather than display:none, so
bots that skip hidden fields still fill it.

Read data-endpoint at submit time rather than caching it at init, keeping the
attribute the single source of truth.

Tests: replace the old contact assertion, which faked a native GET
navigation, with one that mocks the endpoint and exercises the real fetch
path including the posted payload. Add a case for endpoint failure.

typecheck 0/0/0, build 0/0, seo:lint clean on 20 pages, e2e 44 passed.
The 4 remaining failures are the pre-existing stale nav assertions in
docs/launch-checklist.md section 2.1, untouched here.
2026-10-09 07:04:59 -04:00

128 lines
6.4 KiB
YAML

# BlueCap Strategies CI — Gitea Actions (ADR-0007)
#
# Pipeline: install → build (typecheck) → seo:lint → e2e → build & push image to Gitea Packages
# → bump the image tag in k8s/ and commit back to main. ArgoCD then reconciles k3s.
#
# PREREQUISITES (homelab, verify before the first run — see docs/gitops-deployment-strategy.md):
# 1. Docker must be usable from the job container. The runner mounts /var/run/docker.sock; if
# jobs can't see it, enable socket passthrough in act_runner config or switch this to kaniko.
# 2. The RUNNER HOST's dockerd must treat 10.66.15.22:3000 as an insecure (HTTP) registry
# ("insecure-registries": ["10.66.15.22:3000"] in /etc/docker/daemon.json).
# 3. K3S does NOT need registries.yaml — it pulls the same package over public HTTPS
# (git.7tl-homelab.com, valid cert). See ADR-0008. No node config, no cluster restart.
# 4. The Gitea package is PRIVATE; k3s pull auth comes from External Secrets ->
# k8s/externalsecret-registry.yaml -> `gitea-registry` imagePullSecret. See ADR-0008.
# 5. secrets.GITEA_TOKEN (auto-injected per run) needs write access to this repo (tag-bump commit)
# and the package registry.
name: CI
on:
push:
branches: [main]
# Don't re-trigger on the CI tag-bump commit (touches k8s/) or docs-only changes.
paths-ignore:
- 'k8s/**'
- 'docs/**'
- 'planning/**'
- '**/*.md'
env:
# Push over the internal HTTP endpoint (fast, no edge; host dockerd trusts it as insecure).
PUSH_IMAGE: 10.66.15.22:3000/bmr_bluecap/bcs-website
# k3s pulls over the public HTTPS endpoint (valid TLS -> no registries.yaml / node config / restart).
# Same Gitea package as PUSH_IMAGE, just a different access path.
DEPLOY_IMAGE: git.7tl-homelab.com/bmr_bluecap/bcs-website
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node 22
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Build (typecheck + astro build)
run: npm run build
- name: SEO lint
run: npm run seo:lint
# Playwright e2e (headless Chrome) is intentionally NOT run in CI — it's the heaviest step and
# adds little for a static site over `astro build` + seo:lint. Run it locally: `npm run test:e2e`.
- name: Compute image tag
id: tag
run: echo "sha=$(echo ${{ github.sha }} | cut -c1-12)" >> "$GITHUB_OUTPUT"
# Both tools are fetched as STATIC BINARIES, never from distro packages.
# History: this step used `apt-get install -y docker.io`, which broke CI on 2026-08-03 when
# Debian 11 (bullseye — the runner's job image is node:18-bullseye) went EOL and the
# debian-security pool stopped serving those package versions. `apt-get update` still
# succeeds, so the failure surfaces only at install time as a wall of 404s. Static binaries
# have no distro-archive dependency and pin an exact version, so this cannot rot the same way.
- name: Ensure docker + kustomize are available
env:
DOCKER_CLI_VERSION: '28.3.2'
KUSTOMIZE_VERSION: 'v5.4.3'
run: |
set -euo pipefail
if ! command -v docker >/dev/null 2>&1; then
curl -sSL --retry 3 --retry-delay 5 \
"https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz" -o /tmp/docker.tgz
# We only need the client; the daemon is the runner host's, via the mounted socket.
tar xzf /tmp/docker.tgz -C /tmp --strip-components=1 docker/docker
install -m 0755 /tmp/docker /usr/local/bin/docker
fi
if ! command -v kustomize >/dev/null 2>&1; then
curl -sSL --retry 3 --retry-delay 5 \
"https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz" \
| tar xz -C /usr/local/bin
fi
docker version --format 'docker client={{.Client.Version}} server={{.Server.Version}}'
kustomize version
# CI_TOKEN: a Gitea Personal Access Token (scopes: write:package, write:repository) owned by
# the repo owner, stored as a repo Actions secret. The auto GITEA_TOKEN lacks reliable package
# scope on Gitea, hence a dedicated PAT for both the registry push and the tag-bump commit.
- name: Build & push image to Gitea Packages
run: |
echo "${{ secrets.CI_TOKEN }}" | docker login 10.66.15.22:3000 -u "${{ github.repository_owner }}" --password-stdin
# PUBLIC_* values are inlined at build time (static Astro) — they cannot be supplied at
# deploy time. CONTACT_FORM_ENDPOINT is the Formspree URL; set it as a repo Actions
# secret. If it is empty the build still succeeds and the contact form degrades to a
# mailto draft, so a missing secret is survivable but should be caught in review.
docker build \
--build-arg PUBLIC_CONTACT_FORM_ENDPOINT="${{ secrets.CONTACT_FORM_ENDPOINT }}" \
--build-arg PUBLIC_SITE_URL="https://www.bluecapstrategies.com" \
-t "$PUSH_IMAGE:${{ steps.tag.outputs.sha }}" -t "$PUSH_IMAGE:latest" .
# Registry pushes can time out on a slow blob; docker push is resumable, so retry.
push_retry() {
for i in 1 2 3 4 5; do
docker push "$1" && return 0
echo "push of $1 failed (attempt $i), retrying in 10s..."
sleep 10
done
return 1
}
push_retry "$PUSH_IMAGE:${{ steps.tag.outputs.sha }}"
push_retry "$PUSH_IMAGE:latest"
- name: Bump k8s image tag and commit back
run: |
git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions@bmr_bluecap"
# Deployment references the public HTTPS image (what k3s pulls); bump its tag.
(cd k8s && kustomize edit set image "$DEPLOY_IMAGE=$DEPLOY_IMAGE:${{ steps.tag.outputs.sha }}")
git add k8s/kustomization.yaml
git diff --cached --quiet && { echo "no image change"; exit 0; }
git commit -m "ci: deploy ${{ steps.tag.outputs.sha }} [skip ci]"
git remote set-url origin "http://${{ github.repository_owner }}:${{ secrets.CI_TOKEN }}@10.66.15.22:3000/bmr_bluecap/bcs-website.git"
git push origin HEAD:main