Repository navigation
fix(ci): only migrate an environment from its own branch - #9395
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
[High impact] This PR appears safe to merge. SummaryAdds a branch check before checkout and database steps in
No actionable issues found. waleedlatif1 explicitly acknowledges that edited workflows can remove the guard; GitHub Environment protections are deferred to repository admins. Reviews (1) · Last reviewed commit: "fix(ci): only migrate an environment fro..." · Reviewed by Greptile |
This branch was successfully deployed
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.
Summary
migrate.ymltakesworkflow_dispatchwith any environment and reads the database URLs from repo-level secrets, so dispatching it from a feature branch applies that branch's migrations to the chosen database, production includedgithub.refis the environment's own branch: production frommain, staging fromstaging, dev fromdev. Runs before checkout and before any secret is readpromoteinci.ymlrequiresneeds.migrate.result == 'success', and a skipped migrate must never look like one that ranworkflow_call,github.refis the caller's ref, soci.yml's pushes (main-> production,staging-> staging,dev-> dev) pass unchangedscripts/migrations-workflow.test.tsgrabbed the firstrun: |block in the file, which is now the guard; it anchors on the "Apply database schema changes" step insteadconcurrencyblock untouchedDurable fix (not applied here, needs repo admin)
The guard lives in the workflow file, so a dispatch from a branch that edits
migrate.ymlcan still remove it. GitHub Environments close that gap because their branch policies are enforced by GitHub, not the workflow:productionis the same environment as Vercel'sProduction(names are case-insensitive) and gets Vercel deployments on every main push;staginganddevhold old deployments from a previous host. None of them has protection rules today. Using dedicated names (migrate-production,migrate-staging,migrate-dev) avoids putting a required reviewer in front of Vercel's deploymentsmain,staging,devrespectively. Add a required reviewer (and disallow self-review) on the production oneDATABASE_URL+MIGRATION_DATABASE_URLin production,STAGING_DATABASE_URL+STAGING_MIGRATION_DATABASE_URLin staging,DEV_DATABASE_URLin devenvironment: <name for ${{ inputs.environment }}>to themigratejob and drop thesecrets:passthrough from bothci.ymlcallers (environment secrets are resolved in the called job)docs.ymlalso reads repo-levelDATABASE_URL, so either give it the production environment or keep a repo-level copy for itType of Change
Testing
::error::)actionlintonmigrate.ymlandci.yml: clean formigrate.ymlscripts/migrations-workflow.test.tspasses (5 tests)Checklist
test-auditauthoring gate)