Repository navigation
Record the Preview deployment against the pull request head - #682
Merged
Merged
Conversation
The merge gate on main is branch protection's "require deployments to succeed before merging", naming the `Preview` environment - not a status check. GitHub looks for a successful, active `Preview` deployment on the PULL REQUEST HEAD commit. Splitting the preview deploy into a `workflow_run` job moved `environment: Preview` onto a job whose run SHA is main, so GitHub now records that deployment against main and the pull request head gets none. Every pull request is left on "Missing successful active Preview deployment" even with all checks green. Create the deployment explicitly against `workflow_run.head_sha` through the Deployments API, alongside the existing check run, and complete it under `always()` on every path - success with the preview URL, failure otherwise - so it can never be left in progress. `auto_inactive: false` on those statuses stops one pull request's preview from flipping every other pull request's Preview deployment to `inactive`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPMyesYBAqXnBx531rhVbY
Firebase previewPreview URL: https://storj-dev--pr-682-ccp1zipp.web.app Expires: Sat, 26 Sep 2026 06:51:08 GMT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Aleksei A Leonov · Slack thread
Before: the merge gate on
mainis branch protection's "require deployments to succeed before merging", naming thePreviewenvironment — it is not a status check. GitHub looks for a successful, activePreviewdeployment recorded against the pull request head commit. Until #681,environment: Previewsat on thebuild_and_previewjob of apull_requestworkflow, so every run recorded exactly that. #681 movedenvironment: Previewonto thedeploy_previewjob of aworkflow_runworkflow, where the run's SHA ismain— so GitHub now records the deployment againstmainand the pull request head gets none. #680 is the evidence:GET /deployments?sha=96b422bereturns zero deployments, the PR reads "All checks have passed — 2 successful checks" and "Merging is blocked — Missing successful active Preview deployment", while the deploy run created Preview deployment 6538016708 onref: main,sha: 9083f0a9.After: the privileged deploy job creates the
Previewdeployment itself againstgithub.event.workflow_run.head_shaand completes it on every path, so each pull request gets the successful, active Preview deployment on its own head commit that branch protection is looking for — for fork and Dependabot pull requests too, which is what #681 set out to fix.How:
deployments: writeis added to the workflow's permissions. A new step opens the deployment next to the existingDeploy Previewcheck run, before anything can fail, withauto_merge: falseandrequired_contexts: [](without the latter GitHub queues the request instead of creating a deployment) and withtransient_environment/production_environmentboth false, matching the shape of the deployments the old workflow produced. A finalalways()step — mirroring the check run's single close site — setssuccesswith the preview URL asenvironment_url, orfailurewhen the deploy or the upstream build failed, so the deployment can never be leftin_progress. Both statuses passauto_inactive: false, which stops one pull request's preview from flipping every other pull request's Preview deployment toinactive; that is the second half of this problem, and it is why PR #644 still readsblockedtoday with both of its checks green — its head deployment was markedinactiveback on 2026-03-08. TheDeploy Previewcheck run is kept as-is, since branch protection cannot be read from inside a workflow and it may be required too; the comments now say plainly which of the two is the actual gate.Note: this pull request will itself be blocked for exactly the same reason and needs a bypass merge.
workflow_runworkflows only ever run from the copy on the default branch, so the fix cannot produce a Preview deployment for its own head — it only takes effect once it is onmain.One caveat worth stating: the job keeps its job-level
environment: Preview, because the Firebase service account secret may be scoped to that environment and dropping it could silently break secret access. GitHub therefore still records its own Preview deployment againstmainwhen the job ends. Our pull-request-head deployment is completed in the last step of the job so that it lands first; no Preview deployment in this repository has been auto-deactivated since 2026-08-04 (six successful deployments are simultaneously active), so this should not matter, but the ordering is load-bearing and unverified.🤖 Generated with Claude Code
https://claude.ai/code/session_01NPMyesYBAqXnBx531rhVbY
Generated by Claude Code