diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 4f77fc84a7a2..44d8a34ee73a 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -76,6 +76,17 @@ jobs: needs: createNewVersion runs-on: blacksmith-2vcpu-ubuntu-2404 steps: + - name: Check for in-progress deploy on target branch + id: checkInProgressDeploy + run: | + # Capture in-progress deploy URL before we push. The actual Slack post is gated on a successful target-branch push. + DEPLOY_RUN_URL=$(gh api \ + "repos/${{ github.repository }}/actions/workflows/deploy.yml/runs?branch=${{ inputs.TARGET }}&per_page=5" \ + --jq '.workflow_runs[] | select(.status != "completed") | .html_url' | head -n 1) + echo "DEPLOY_RUN_URL=$DEPLOY_RUN_URL" >> "$GITHUB_OUTPUT" + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Extract PR information # 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. if: ${{ inputs.PULL_REQUEST_URL != '' }} @@ -229,6 +240,22 @@ jobs: git push origin ${{ inputs.TARGET }} fi + - name: Warn that previous deploy was superseded + if: ${{ steps.cherryPick.outputs.HAS_CONFLICTS != 'true' && steps.checkInProgressDeploy.outputs.DEPLOY_RUN_URL != '' }} + uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e + with: + status: custom + custom_payload: | + { + channel: '#deployer', + attachments: [{ + color: 'warning', + text: `⚠️ ${{ inputs.TARGET == 'production' && 'Production' || 'Staging' }} <${{ steps.checkInProgressDeploy.outputs.DEPLOY_RUN_URL }}|deploy> cancelled by new cherry-pick` + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + - name: Find deploy workflow run # Also runs for version-bump-only CPs where HAS_CONFLICTS is unset if: ${{ steps.cherryPick.outputs.HAS_CONFLICTS != 'true' }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 36e31a3d2ca9..56b0de5fd104 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -649,6 +649,42 @@ jobs: with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + postSlackMessageOnCancellation: + name: Post a Slack message when the deploy is cancelled manually + runs-on: blacksmith-2vcpu-ubuntu-2404 + if: ${{ cancelled() }} + needs: [androidBuild, androidUploadGooglePlay, androidSubmit, iosBuild, iosUploadTestflight, iosSubmit, webBuild, webDeploy] + steps: + - name: Check whether a newer deploy run exists + id: check + run: | + # If a newer run exists, the cherry-pick workflow already announced this. Skip to avoid double-posting. + LATEST=$(gh api \ + "repos/${{ github.repository }}/actions/workflows/deploy.yml/runs?branch=${{ github.ref_name }}&per_page=1" \ + --jq '.workflow_runs[0].id') + if [ "$LATEST" != "${{ github.run_id }}" ]; then + echo "SKIP=true" >> "$GITHUB_OUTPUT" + fi + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Post Slack message on manual cancellation + if: ${{ steps.check.outputs.SKIP != 'true' }} + # v3 + uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e + with: + status: custom + custom_payload: | + { + channel: '#deployer', + attachments: [{ + color: 'warning', + text: `⚠️ ${{ github.ref == 'refs/heads/production' && 'Production' || 'Staging' }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|deploy> cancelled manually` + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + checkDeploymentSuccess: runs-on: blacksmith-2vcpu-ubuntu-2404 outputs: