File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4848 cancel-in-progress : false
4949
5050 steps :
51+ # An environment only migrates from its own branch, so a manual dispatch
52+ # from a feature branch cannot apply that branch's migrations to a shared
53+ # database. Under workflow_call github.ref is the caller's ref (ci.yml's
54+ # push to main/staging/dev). This fails rather than skips: ci.yml's
55+ # promote gates on migrate succeeding, and a skipped run must never read
56+ # as a migration that happened. It runs before any secret is read.
57+ - name : Require the environment's own branch
58+ env :
59+ ENVIRONMENT : ${{ inputs.environment }}
60+ REF : ${{ github.ref }}
61+ run : |
62+ case "${ENVIRONMENT}" in
63+ production) expected=refs/heads/main ;;
64+ staging) expected=refs/heads/staging ;;
65+ dev) expected=refs/heads/dev ;;
66+ *)
67+ echo "::error::Unknown migrate environment '${ENVIRONMENT}'"
68+ exit 1
69+ ;;
70+ esac
71+ if [ "${REF}" != "${expected}" ]; then
72+ echo "::error::Refusing to migrate ${ENVIRONMENT} from ${REF}; ${ENVIRONMENT} migrates only from ${expected}"
73+ exit 1
74+ fi
75+
5176 - name : Checkout code
5277 uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
5378 with :
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ import { readFileSync } from 'node:fs'
33import { describe , expect , it } from 'vitest'
44
55const workflow = readFileSync ( new URL ( '../.github/workflows/migrate.yml' , import . meta. url ) , 'utf8' )
6- const step = workflow . match ( / ^ { 8 } r u n : \| \r ? \n ( (?: { 10 } .* (?: \r ? \n | $ ) | \r ? \n ) + ) / m) ?. [ 1 ]
6+ const step = workflow . match (
7+ / ^ { 6 } - n a m e : A p p l y d a t a b a s e s c h e m a c h a n g e s \r ? \n (?: { 8 } .* \r ? \n ) * ? { 8 } r u n : \| \r ? \n ( (?: { 10 } .* (?: \r ? \n | $ ) | \r ? \n ) + ) / m
8+ ) ?. [ 1 ]
79if ( ! step ) throw new Error ( 'Migration workflow must contain its schema application shell step' )
810const script = step . replace ( / ^ { 10 } / gm, '' )
911
You can’t perform that action at this time.
0 commit comments