Skip to content

Prod environment, phone.pixelbar.nl and the Release workflow (#20) - #45

Merged
NinjaLikesCheez merged 1 commit into
mainfrom
claude/20-prod
Nov 18, 2026
Merged

NinjaLikesCheez merged 1 commit into
mainfrom
claude/20-prod

Conversation

@NinjaLikesCheez

Copy link
Copy Markdown
Contributor

Closes #20.

Needs a human reviewer. This adds the workflow that rolls prod (release.yml, job prod-cd) and the Terraform for the stack that answers the real doorbell. It doesn't touch src/http/auth*, the webhook signature check or the accept route.

What

  • infra/envs/prod. The dev module in pixel-phone-prod, with Key Vault purge protection, the real ringing helper (input_boolean.pixel_phone_ringing), and Pixel prod's identity (69f18339-…) on phone-events. Every feature starts off. Terraform creates the app from :main and then ignores the image. A maintainer applies it (PIXEL_PHONE_APPLY_PROD=1 just tf-apply prod).
  • phone.pixelbar.nl. The module now has custom_domains, done as spacestate does it: domain.tf and hostname.sh attach the hostname, issue a managed certificate validated by CNAME, and bind it, all in one apply. The DNS records are made by hand first (infra/envs/prod/README.md). A new precondition stops prod from using a _dev helper.
  • release.yml (Pixel ADR 0013): just check → just bump --commit → push the tag → GitHub Release → GHCR :<sha>, :vX.Y.Z, :main (with an anonymous-pull check) → Sentry release (environment prod) → docs site through docs.yml. Then prod-cd in Environment prod (required reviewer, main only) runs az containerapp update and waits for /version to report the SHA. It refuses unless the app says PIXEL_PHONE_ENV=prod. It never applies Terraform.
  • just release starts it. just rollback <env> <sha|vX.Y.Z> checks the image can be pulled and that it's rolling the right environment, asks before touching prod, and waits for the new revision.
  • Docs. docs/setup.md, Setting up from nothing, goes from an empty subscription through the bootstrap, repository settings, dev and prod to the prod number, in order and with a check for each part. The runbook adds Releasing, Rolling back, Rotating a secret (each of the five), and prod rows under "When the doorbell doesn't ring". ADR 0011 records the decisions.
  • Tests. tests/scripts/workflows.test.ts checks that only the Release workflow names pixel-phone-prod or uses Environment prod, that it only runs on dispatch from main, and that only prod-cd logs in to Azure. envs.test.ts now checks the prod stack against scripts/envs.ts.

Decisions to look at

  • CI doesn't plan prod. Environment prod has a required reviewer and deploys from main only, so a PR job can't use its identity, and a plan on main would wait for an approval. just tf-validate still checks envs/prod; a maintainer runs just tf-plan prod. (Pixel plans prod in CI, but its prod environment has no protection rules.)
  • The Sentry release skips with a warning while SENTRY_AUTH_TOKEN is unset, as CD already does, instead of failing every release.
  • The image version is the SHA, as in CD and Pixel, so /version and the Sentry release match the :<sha> tag.

Checked

  • just check: 283 tests pass. just docs-build passes with no dead links, and every new anchor resolves.
  • just tf-validate and terraform fmt pass. shellcheck passes on hostname.sh.
  • just tf-plan prod: 21 to add, 0 to change. With custom_domains = ["phone.pixelbar.nl"]: 24 to add, and webhook_url becomes https://phone.pixelbar.nl/webhooks/telnyx.
  • just tf-plan dev: the module change adds nothing. The plan still shows 1 change from drift that was already there: live dev runs with Home Assistant and the accept API on, but infra/envs/dev/terraform.example.tfvars doesn't say so. Not fixed here.
  • just rollback dev no-such-tag refuses without touching dev.

Not done (needs a person)

None of #20's acceptance criteria can be checked until someone with access does these steps, which Setting up from nothing → 5. prod lists in order:

  • apply prod
  • make the DNS records
  • push prod's secrets
  • upload the recording
  • enable GitHub Pages
  • run the first release

The prod number is #21.

🤖 Generated with Claude Code

…20)

- infra/envs/prod: the dev module in pixel-phone-prod, Key Vault purge
  protection, the real ringing helper, Pixel prod's queue access. Applied
  by a maintainer only; CI validates it but can't plan it (Environment
  prod needs approval and deploys from main).
- Custom domains in the module, bound with a managed certificate in three
  steps through hostname.sh, as spacestate does.
- release.yml: just check, just bump --commit, tag, GitHub Release, GHCR
  :<sha>/:vX.Y.Z/:main, Sentry release (prod), docs site, then roll
  pixel-phone-prod after approval.
- just release and just rollback <env> <tag>.
- ADR 0011, docs/setup.md (from nothing to prod), runbook sections for
  releasing, rolling back and rotating each secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines +343 to +348
echo "::notice::pixel-phone-prod runs ${TAG} (${SHA}). To roll back: just rollback prod ${previous##*:}"
exit 0
fi
sleep 5
done
echo "::error::pixel-phone-prod didn't report ${SHA} within 150 s. It was running ${previous}; to roll back: just rollback prod ${previous##*:}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: During the first release, the suggested rollback command targets main, which has already been updated to the failing image build.
Severity: LOW

Suggested Fix

Handle the case where previous image tag is main. Warn the operator that rollback is not possible for the initial release seeded by :main, or suppress the rollback suggestion if the previous image was not pinned to a specific SHA.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: .github/workflows/release.yml#L343-L348

Potential issue: When the initial release workflow runs, the production container app is
still using its seed image tag `ghcr.io/pixelbar/pixel-phone:main`. During the `publish`
job, `:main` is updated to point to the new build. If deployment fails during this first
release, the failure message outputs `just rollback prod ${previous##*:}` (evaluating to
`just rollback prod main`). Running this suggested command will pull the newly updated
`:main` image rather than rolling back to the previous deployment.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: on the first release prod still runs the seed :main, and publish has already moved :main to the new build. Fixed in 43861ae. prod-cd now suggests a rollback only when prod ran a full SHA or vX.Y.Z; otherwise it says there is no earlier release to roll back to. just rollback also refuses main, dev and other moving tags.

@NinjaLikesCheez
NinjaLikesCheez merged commit 25daef1 into main Nov 18, 2026
10 checks passed
NinjaLikesCheez added a commit that referenced this pull request Nov 18, 2026
The first release replaces the :main prod was created with, and publish has
already moved :main to the new build, so `just rollback prod main` would not
roll anything back. Found by Sentry's review on #45.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NinjaLikesCheez added a commit that referenced this pull request Nov 18, 2026
Suggest a prod rollback only to a pinned release (#45 follow-up)

This branch was successfully deployed

1 active deployment
dev — b05dabb1 Deployed Nov 18, 2026 by NinjaLikesCheez via Plan envs/dev #41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prod environment, phone.pixelbar.nl and the Release workflow

1 participant