@@ -2,8 +2,8 @@ name: Deployment v2
22
33on :
44 push :
5- branches : [ main ]
6- tags : [ cowswap-*, explorer-* ]
5+ branches : [main]
6+ tags : [cowswap-*, explorer-*]
77
88concurrency :
99 group : ${{ startsWith(github.ref, 'refs/tags/') && format('release-tag-{0}', github.sha) || 'release-branch-sync' }}
@@ -19,11 +19,13 @@ jobs:
1919 if : startsWith(github.ref, 'refs/tags/')
2020 runs-on : ubuntu-latest
2121 outputs :
22+ release-commit : ${{ steps.collect.outputs.release-commit }}
2223 release-tags : ${{ steps.collect.outputs.release-tags }}
2324 steps :
2425 - name : Checkout code
2526 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2627 with :
28+ ref : refs/heads/main
2729 fetch-depth : 0
2830 persist-credentials : false
2931
3234 run : |
3335 set -euo pipefail
3436
35- git fetch --tags origin
37+ git fetch --tags origin main
3638
3739 release_commit="$(git rev-list -n 1 "${GITHUB_REF}")"
40+
41+ if ! git merge-base --is-ancestor "${release_commit}" "origin/main"; then
42+ echo "::error::Release tag ${GITHUB_REF_NAME} does not point to a commit reachable from origin/main"
43+ exit 1
44+ fi
45+
3846 release_tags="$(
3947 git tag --points-at "${release_commit}" \
4048 | sort \
4553 release_tags="${GITHUB_REF_NAME}"
4654 fi
4755
56+ echo "release-commit=${release_commit}" >> "$GITHUB_OUTPUT"
4857 echo "release-tags=${release_tags}" >> "$GITHUB_OUTPUT"
4958
5059 sync-develop :
6170 - name : Checkout workflow repository
6271 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6372 with :
73+ ref : refs/heads/main
6474 fetch-depth : 0
6575 persist-credentials : false
6676
@@ -132,6 +142,7 @@ jobs:
132142 - name : Checkout workflow repository
133143 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
134144 with :
145+ ref : refs/heads/main
135146 fetch-depth : 0
136147 persist-credentials : false
137148
@@ -148,15 +159,17 @@ jobs:
148159 run : |
149160 set -euo pipefail
150161
151- git fetch origin main staging
162+ git fetch origin main staging --tags
152163 git checkout -B staging origin/staging
153- git merge --ff-only origin/main
164+ git merge --ff-only "${RELEASE_COMMIT}"
154165 git push origin staging
166+ env :
167+ RELEASE_COMMIT : ${{ needs.collect-release-metadata.outputs.release-commit }}
155168
156169 notify-production-approval :
157170 name : Notify Slack for production approval
158171 if : startsWith(github.ref, 'refs/tags/cowswap-') || startsWith(github.ref, 'refs/tags/explorer-')
159- needs : [ collect-release-metadata, sync-staging ]
172+ needs : [collect-release-metadata, sync-staging]
160173 runs-on : ubuntu-latest
161174 steps :
162175 - name : Notify Slack
@@ -174,13 +187,14 @@ jobs:
174187 sync-production :
175188 name : Fast-forward production to main
176189 if : startsWith(github.ref, 'refs/tags/cowswap-') || startsWith(github.ref, 'refs/tags/explorer-')
177- needs : [ collect-release-metadata, notify-production-approval ]
190+ needs : [collect-release-metadata, notify-production-approval]
178191 runs-on : ubuntu-latest
179192 environment : production # Env configured in GitHub UI. Requires manual approval before this job can run
180193 steps :
181194 - name : Checkout workflow repository
182195 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
183196 with :
197+ ref : refs/heads/main
184198 fetch-depth : 0
185199 persist-credentials : false
186200 - name : Setup release sync
@@ -196,7 +210,9 @@ jobs:
196210 run : |
197211 set -euo pipefail
198212
199- git fetch origin main production
213+ git fetch origin main production --tags
200214 git checkout -B production origin/production
201- git merge --ff-only origin/main
215+ git merge --ff-only "${RELEASE_COMMIT}"
202216 git push origin production
217+ env :
218+ RELEASE_COMMIT : ${{ needs.collect-release-metadata.outputs.release-commit }}
0 commit comments