Skip to content

Commit 2a1f5cd

Browse files
committed
Gate cherry-pick supersede notification on successful target-branch push
1 parent 281e9e6 commit 2a1f5cd

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

.github/workflows/cherryPick.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,6 @@ jobs:
3737
validate:
3838
runs-on: blacksmith-2vcpu-ubuntu-2404
3939
steps:
40-
- name: Check for in-progress deploy on target branch
41-
id: checkInProgressDeploy
42-
run: |
43-
# Is a deploy currently running on the target branch? If so, this CP will supersede it.
44-
DEPLOY_RUN_URL=$(gh api \
45-
"repos/${{ github.repository }}/actions/workflows/deploy.yml/runs?branch=${{ inputs.TARGET }}&per_page=5" \
46-
--jq '.workflow_runs[] | select(.status != "completed") | .html_url' | head -n 1)
47-
echo "DEPLOY_RUN_URL=$DEPLOY_RUN_URL" >> "$GITHUB_OUTPUT"
48-
env:
49-
GITHUB_TOKEN: ${{ github.token }}
50-
51-
- name: Warn that previous deploy will be superseded
52-
if: ${{ steps.checkInProgressDeploy.outputs.DEPLOY_RUN_URL != '' }}
53-
uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e
54-
with:
55-
status: custom
56-
custom_payload: |
57-
{
58-
channel: '#deployer',
59-
attachments: [{
60-
color: 'warning',
61-
text: `⚠️ ${{ inputs.TARGET == 'production' && 'Production' || 'Staging' }} <${{ steps.checkInProgressDeploy.outputs.DEPLOY_RUN_URL }}|deploy> cancelled by new cherry-pick`
62-
}]
63-
}
64-
env:
65-
GITHUB_TOKEN: ${{ github.token }}
66-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
67-
6840
- name: Validate pull request URL
6941
if: ${{ inputs.PULL_REQUEST_URL != '' }}
7042
run: |
@@ -104,6 +76,17 @@ jobs:
10476
needs: createNewVersion
10577
runs-on: blacksmith-2vcpu-ubuntu-2404
10678
steps:
79+
- name: Check for in-progress deploy on target branch
80+
id: checkInProgressDeploy
81+
run: |
82+
# Capture in-progress deploy URL before we push. The actual Slack post is gated on a successful target-branch push.
83+
DEPLOY_RUN_URL=$(gh api \
84+
"repos/${{ github.repository }}/actions/workflows/deploy.yml/runs?branch=${{ inputs.TARGET }}&per_page=5" \
85+
--jq '.workflow_runs[] | select(.status != "completed") | .html_url' | head -n 1)
86+
echo "DEPLOY_RUN_URL=$DEPLOY_RUN_URL" >> "$GITHUB_OUTPUT"
87+
env:
88+
GITHUB_TOKEN: ${{ github.token }}
89+
10790
- name: Extract PR information
10891
# Note: this step is only skipped when there's no PULL_REQUEST_URL, which is only ever be the case when we're CPing just a version bump.
10992
if: ${{ inputs.PULL_REQUEST_URL != '' }}
@@ -257,6 +240,23 @@ jobs:
257240
git push origin ${{ inputs.TARGET }}
258241
fi
259242
243+
- name: Warn that previous deploy was superseded
244+
if: ${{ steps.cherryPick.outputs.HAS_CONFLICTS != 'true' && steps.checkInProgressDeploy.outputs.DEPLOY_RUN_URL != '' }}
245+
uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e
246+
with:
247+
status: custom
248+
custom_payload: |
249+
{
250+
channel: '#deployer',
251+
attachments: [{
252+
color: 'warning',
253+
text: `⚠️ ${{ inputs.TARGET == 'production' && 'Production' || 'Staging' }} <${{ steps.checkInProgressDeploy.outputs.DEPLOY_RUN_URL }}|deploy> cancelled by new cherry-pick`
254+
}]
255+
}
256+
env:
257+
GITHUB_TOKEN: ${{ github.token }}
258+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
259+
260260
- name: Find deploy workflow run
261261
# Also runs for version-bump-only CPs where HAS_CONFLICTS is unset
262262
if: ${{ steps.cherryPick.outputs.HAS_CONFLICTS != 'true' }}

0 commit comments

Comments
 (0)