Skip to content

ci: label-gated PR preview deploys to Cloud Run - #7

Open
chasetmartin wants to merge 4 commits into
mainfrom
W10-preview-builds
Open

chasetmartin wants to merge 4 commits into
mainfrom
W10-preview-builds

Conversation

@chasetmartin

@chasetmartin chasetmartin commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds .github/workflows/preview.yml, which deploys a per-PR preview of the SPA to Cloud Run. Previews are opt-in with a preview label.

  • Add preview: builds the PR's merge commit into its own service (newweaver-pr-<number>) and posts the URL in a single PR comment, which is updated on each deploy.
  • Push while labeled: redeploys. Repeat builds reuse the GHA layer cache.
  • Remove the label, or close/merge the PR: deletes the service. Images stay in Artifact Registry.
  • Other label changes: ignored. Fork PRs are skipped because they get no OIDC token.

It reuses the Workload Identity Federation setup and repo variables from deploy.yml. PostHog is left unconfigured, so previews don't send events to production analytics.

Replaces #6.

Test plan

  • Add preview to this PR. The service deploys and the comment shows a working URL.
  • Push a commit. The service redeploys and the same comment is updated.
  • Add and remove an unrelated label. No deploy or teardown runs.
  • Remove preview. The service is deleted.

chasetmartin and others added 4 commits September 30, 2026 13:42
Each PR builds its merge result into its own Cloud Run service
(newweaver-pr-<number>) and keeps a single PR comment updated with the
URL. Closing the PR deletes the service and its images. Reuses the
Workload Identity Federation setup from deploy.yml; fork PRs are
skipped since they get no OIDC token. Builds use the GHA layer cache so
repeat pushes skip the pnpm install. PostHog is left unconfigured so
previews don't send events to production analytics.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Previews now deploy only while the PR carries the "preview" label:
adding it deploys immediately, pushes redeploy while it is on, and
removing it (or closing the PR) tears the preview down. Other label
changes are ignored.

Concurrency moves from the workflow to the deploy/teardown jobs so runs
triggered by unrelated label events, whose jobs all skip, can't cancel
an in-flight deploy.
Teardown now deletes only the Cloud Run service. Images stay in
Artifact Registry, so the deploy service account doesn't need delete
rights on the repository.
@chasetmartin chasetmartin added the preview Deploy a Cloud Run preview for this PR label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Preview: https://newweaver-pr-7-auejgdbofq-uc.a.run.app

Built from the merge of c735fd8 into main (merge commit 9b1bb12). Deleted when this PR closes or the preview label is removed.

@chasetmartin
chasetmartin requested review from jirhiker and a balanced review from Copilot and removed request for Copilot October 1, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Deploy a Cloud Run preview for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant