|
37 | 37 | validate: |
38 | 38 | runs-on: blacksmith-2vcpu-ubuntu-2404 |
39 | 39 | 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 | | - |
68 | 40 | - name: Validate pull request URL |
69 | 41 | if: ${{ inputs.PULL_REQUEST_URL != '' }} |
70 | 42 | run: | |
@@ -104,6 +76,17 @@ jobs: |
104 | 76 | needs: createNewVersion |
105 | 77 | runs-on: blacksmith-2vcpu-ubuntu-2404 |
106 | 78 | 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 | + |
107 | 90 | - name: Extract PR information |
108 | 91 | # 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. |
109 | 92 | if: ${{ inputs.PULL_REQUEST_URL != '' }} |
@@ -257,6 +240,23 @@ jobs: |
257 | 240 | git push origin ${{ inputs.TARGET }} |
258 | 241 | fi |
259 | 242 |
|
| 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 | + |
260 | 260 | - name: Find deploy workflow run |
261 | 261 | # Also runs for version-bump-only CPs where HAS_CONFLICTS is unset |
262 | 262 | if: ${{ steps.cherryPick.outputs.HAS_CONFLICTS != 'true' }} |
|
0 commit comments