Skip to content

Commit 4f29475

Browse files
authored
Support promoting patch releases which do not merge to main (kroxylicious#2869)
Signed-off-by: Sam Barker <[email protected]>
1 parent 83534fe commit 4f29475

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

.github/workflows/promote_release.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ jobs:
125125
GH_TOKEN: ${{ secrets.KROXYLICIOUS_RELEASE_TOKEN }}
126126
run: |
127127
echo "PR_BRANCH=$(gh pr view ${{ inputs.release-pr-issue-number}} --json headRefName | jq -r .headRefName)" >> $GITHUB_ENV
128+
echo "PR_BASE_BRANCH=$(gh pr view ${{ inputs.release-pr-issue-number}} --json baseRefName | jq -r .baseRefName)" >> $GITHUB_ENV
128129
129130
- name: 'Branch name matches naming conventions'
130131
env:
@@ -151,19 +152,19 @@ jobs:
151152
echo "PR_REF=$(git rev-list -n 1 origin/${PR_BRANCH})" >> $GITHUB_ENV
152153
153154
# Get main's current head
154-
echo "MAIN_HEAD=$(git rev-list -n 1 main)" >> $GITHUB_ENV
155+
echo "PR_BASE_HEAD=$(git rev-list -n 1 ${PR_BASE_BRANCH} )" >> $GITHUB_ENV
155156
156157
# Get PR's view of where main ought to be. This is two commits behind PR's head.
157-
echo "PR_MAIN_REF=$(git rev-list -n 1 origin/${PR_BRANCH}^^)" >> $GITHUB_ENV
158+
echo "PR_BASE_REF=$(git rev-list -n 1 origin/${PR_BRANCH}^^)" >> $GITHUB_ENV
158159
159160
- name: 'Check for PR/main divergence'
160161
if: ${{ inputs.command == 'promote-release' }}
161162
env:
162163
GH_TOKEN: ${{ secrets.KROXYLICIOUS_RELEASE_TOKEN }}
163164
run: |
164-
if [[ "${MAIN_HEAD}" != "${PR_MAIN_REF}" ]];
165+
if [[ "${PR_BASE_HEAD}" != "${PR_BASE_REF}" ]];
165166
then
166-
gh pr comment --body "Release PR (expects main ${PR_MAIN_REF}) has diverged from main (${MAIN_HEAD}). You must drop this release and restage the release." ${{ inputs.release-pr-issue-number }}
167+
gh pr comment --body "Release PR (expects ${PR_BASE_BRANCH} to be at ${PR_BASE_REF}) but has found (${PR_BASE_HEAD}). You must drop this release and restage the release." ${{ inputs.release-pr-issue-number }} as there have been commits to ${PR_BASE_BRANCH} since the release was staged.
167168
exit 1
168169
fi
169170

0 commit comments

Comments
 (0)