Skip to content

Commit

Permalink
Merge pull request #45096 from Expensify/jpersaud_deploy_failure_slack
Browse files Browse the repository at this point in the history
[No QA] Add failure notification if staging/production fail to deploy
  • Loading branch information
roryabraham authored Jul 9, 2024
2 parents 1534ac2 + 32b8f19 commit 43502d5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ jobs:

- name: 🚀 Push tags to trigger staging deploy 🚀
run: git push --tags

- name: Warn deployers if staging deploy failed
if: ${{ failure() }}
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
channel: '#deployer',
attachments: [{
color: "#DB4545",
pretext: `<!subteam^S4TJJ3PSL>`,
text: `💥 NewDot staging deploy failed. 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

deployProduction:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -65,6 +83,24 @@ jobs:
PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }}

- name: 🚀 Create release to trigger production deploy 🚀
run: gh release create ${{ env.PRODUCTION_VERSION }} --generate-notes
run: gh release create ${{ env.PRODUCTION_VERSION }} --notes '${{ steps.getReleaseBody.outputs.RELEASE_BODY }}'
env:
GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }}

- name: Warn deployers if production deploy failed
if: ${{ failure() }}
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
channel: '#deployer',
attachments: [{
color: "#DB4545",
pretext: `<!subteam^S4TJJ3PSL>`,
text: `💥 NewDot production deploy failed. 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
4 changes: 4 additions & 0 deletions workflow_tests/mocks/deployMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = createMockStep('Setup git for OSBot
]);
const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = createMockStep('Tag version', 'Tagging new version', 'DEPLOY_STAGING');
const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = createMockStep('🚀 Push tags to trigger staging deploy 🚀', 'Pushing tag to trigger staging deploy', 'DEPLOY_STAGING');
const DEPLOY_STAGING__WARN_DEPLOYERS__STEP_MOCK = createMockStep('Warn deployers if staging deploy failed', 'Warning deployers in slack for workflow failure', 'DEPLOY_STAGING');
const DEPLOY_STAGING_STEP_MOCKS = [
DEPLOY_STAGING__CHECKOUT__STEP_MOCK,
DEPLOY_STAGING__SETUP_GIT__STEP_MOCK,
DEPLOY_STAGING__TAG_VERSION__STEP_MOCK,
DEPLOY_STAGING__PUSH_TAG__STEP_MOCK,
DEPLOY_STAGING__WARN_DEPLOYERS__STEP_MOCK,
] as const satisfies StepIdentifier[];

const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['ref', 'token']);
Expand Down Expand Up @@ -47,13 +49,15 @@ const DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK = createMockStep(
[],
['GITHUB_TOKEN'],
);
const DEPLOY_PRODUCTION__WARN_DEPLOYERS__STEP_MOCK = createMockStep('Warn deployers if production deploy failed', 'Warning deployers in slack for workflow failure', 'DEPLOY_STAGING');
const DEPLOY_PRODUCTION_STEP_MOCKS = [
DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK,
DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK,
DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK,
DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK,
DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK,
DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK,
DEPLOY_PRODUCTION__WARN_DEPLOYERS__STEP_MOCK,
] as const satisfies StepIdentifier[];

export default {DEPLOY_STAGING_STEP_MOCKS, DEPLOY_PRODUCTION_STEP_MOCKS};

0 comments on commit 43502d5

Please sign in to comment.