From e183510466488ee27cf559a853f77ba93e3b9d0d Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Sat, 7 Nov 2026 16:29:56 +0100 Subject: [PATCH] DNS from CI: preview on every push, applied by hand on main dns.yml runs DNSControl on kasse's host runner with the repo secret CLOUDFLARE_API_TOKEN: check and preview on any push touching dns/, push only from Run workflow on main, so a merge is never the cutover. Push events only; the repo is public. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM --- .gitea/workflows/dns.yml | 61 ++++++++++++++++++++++++++++++++++++++++ dns/README.md | 15 ++++++++-- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/dns.yml diff --git a/.gitea/workflows/dns.yml b/.gitea/workflows/dns.yml new file mode 100644 index 0000000..d124ce8 --- /dev/null +++ b/.gitea/workflows/dns.yml @@ -0,0 +1,61 @@ +# tomtervel.no's DNS: dns/dnsconfig.js, applied to Cloudflare by +# DNSControl on kasse's host runner. A push that touches dns/, on any +# branch, shows what would change (`preview`) and changes nothing. The +# change itself is a person's: Actions -> dns -> Run workflow, on main. +# So merging is not the cutover; pressing the button is. +# +# Push only, never pull_request: the repo is public, and a stranger's pull +# request must not run on kasse with the token. The token is the repo +# secret CLOUDFLARE_API_TOKEN, DNS edit for tomtervel.no only +# (dns/README.md). +name: dns +on: + push: + paths: + - dns/** + - .gitea/workflows/dns.yml + workflow_dispatch: + +jobs: + dns: + runs-on: fish + env: + DNSCONTROL_VERSION: 5.7.2 + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + steps: + - name: checkout + run: | + rm -rf checkout + git clone --depth 1 --branch "${{ github.ref_name }}" "${{ github.server_url }}/${{ github.repository }}.git" checkout + + # The release binary, checked against the release's own checksums, + # kept beside the portal lint so each version is fetched once. + - name: dnscontrol + run: | + bin="/var/local/cargo-target/dnscontrol-$DNSCONTROL_VERSION" + if [ ! -x "$bin" ]; then + tmp=$(mktemp -d) + base="https://github.com/StackExchange/dnscontrol/releases/download/v$DNSCONTROL_VERSION" + tar="dnscontrol_${DNSCONTROL_VERSION}_linux_amd64.tar.gz" + curl -sfL "$base/$tar" -o "$tmp/$tar" + curl -sfL "$base/checksums.txt" -o "$tmp/checksums.txt" + (cd "$tmp" && grep " $tar\$" checksums.txt | sha256sum -c -) + tar -xzf "$tmp/$tar" -C "$tmp" dnscontrol + install -m 0755 "$tmp/dnscontrol" "$bin" + rm -rf "$tmp" + fi + "$bin" version + echo "DNSCONTROL=$bin" >> "$GITHUB_ENV" + + - name: check + working-directory: checkout/dns + run: $DNSCONTROL check + + - name: preview + working-directory: checkout/dns + run: $DNSCONTROL preview + + - name: push + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' + working-directory: checkout/dns + run: $DNSCONTROL push diff --git a/dns/README.md b/dns/README.md index ffef800..24cf4cd 100644 --- a/dns/README.md +++ b/dns/README.md @@ -5,6 +5,16 @@ The zone is `dnsconfig.js`, applied to Cloudflare with the file with the live zone, so it can be run by anyone with the token, from any machine. +## From CI + +`.gitea/workflows/dns.yml` runs on kasse's host runner. Every push that +touches `dns/`, on any branch, runs `check` and `preview`: the run's log +is the diff, and nothing changes. Applying it is a person pressing +**Actions -> dns -> Run workflow** on `main`, so merging is never the +cutover by accident. The token is the repo secret `CLOUDFLARE_API_TOKEN`. + +## By hand + ```sh paru -S dnscontrol cd dns @@ -48,8 +58,9 @@ Nothing about Zoho's MX should appear. 1. On kasse, `kasse-dkim-tomtervel.sh` makes the vel's signing key and prints its public half. Put it in `KASSE_DKIM`. -2. `dnscontrol push`. The apex leaves the old website at this moment. -3. `.env` here: `PORTAL_HOST=tomtervel.no`, `ID_HOST=id.tomtervel.no`, +2. Actions -> dns -> Run workflow on main (or `dnscontrol push`). The apex + leaves the old website at this moment. +3. A commit to `.env`: `PORTAL_HOST=tomtervel.no`, `ID_HOST=id.tomtervel.no`, `CHAT_HOST=chat.tomtervel.no`, and the Caddy blocks in `host-caddy/` on kasse; Kanidm's domain is renamed before anyone but the first person has a passkey.