Skip to content

Commit 4a534c5

Browse files
authored
Standardized slack alert fails (#44074)
1 parent 4465644 commit 4a534c5

File tree

78 files changed

+473
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+473
-166
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Send Slack notification if workflow fails
2+
description: Send Slack notification if workflow fails
3+
4+
inputs:
5+
slack_channel_id:
6+
description: Slack channel ID
7+
required: true
8+
slack_token:
9+
description: Slack token
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Send Slack notification if workflow fails
16+
uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad
17+
if: >-
18+
${{
19+
failure() &&
20+
env.FREEZE != 'true' &&
21+
github.repository == 'github/docs-internal' &&
22+
github.event_name != 'pull_request' &&
23+
github.event_name != 'pull_request_target'
24+
}}
25+
with:
26+
channel: ${{ inputs.slack_channel_id }}
27+
bot-token: ${{ inputs.slack_token }}
28+
color: failure
29+
text: The last '${{ github.workflow }}' run failed. See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

.github/workflows/add-review-template.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ jobs:
3737
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }}
3838
PR: ${{ github.event.pull_request.html_url }}
3939
TEMPLATE: ${{ env.TEMPLATE }}
40+
41+
- uses: ./.github/actions/slack-alert
42+
with:
43+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
44+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/auto-close-dependencies.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ jobs:
6666
console.error(`Failed to lock the pull request. Error: ${error}`)
6767
throw error
6868
}
69+
70+
- uses: ./.github/actions/slack-alert
71+
with:
72+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
73+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/azure-preview-env-deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,8 @@ jobs:
254254
# The `--fail --retry N` combination means that a 4xx response
255255
# code will exit immediately but a 5xx will exhaust the retries.
256256
run: curl --fail --retry-connrefused --retry 5 -I ${{ env.APP_URL }}
257+
258+
- uses: ./.github/actions/slack-alert
259+
with:
260+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
261+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/azure-preview-env-destroy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ concurrency:
2525
cancel-in-progress: true
2626

2727
jobs:
28-
destory-azure-preview-env:
28+
destroy-azure-preview-env:
2929
name: Destroy
3030
runs-on: ubuntu-latest
3131
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
@@ -70,3 +70,8 @@ jobs:
7070
# The token provided by the workflow does not have the permissions to delete created environments
7171
token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }}
7272
environment: preview-env-${{ env.PR_NUMBER }}
73+
74+
- uses: ./.github/actions/slack-alert
75+
with:
76+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
77+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/azure-prod-build-deploy.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ jobs:
146146
run: |
147147
az webapp deployment slot swap --slot canary --target-slot production -n ghdocs-prod -g docs-prod
148148
149-
- name: Send Slack notification if workflow failed
150-
uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad
151-
if: ${{ failure() }}
149+
- uses: ./.github/actions/slack-alert
152150
with:
153-
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
154-
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
155-
color: failure
156-
text: Production deployment (Azure) failed at commit ${{ github.sha }}. See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
151+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
152+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/azure-staging-build-deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,8 @@ jobs:
157157
- name: 'Swap deployment slot to production'
158158
run: |
159159
az webapp deployment slot swap --slot ${{ env.SLOT_NAME }} --target-slot production -n ${{ env.APP_SERVICE_NAME }} -g ${{ env.RESOURCE_GROUP_NAME }}
160+
161+
- uses: ./.github/actions/slack-alert
162+
with:
163+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
164+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/check-broken-links-github-github.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ jobs:
8787
repository: ${{ env.REPORT_REPOSITORY }}
8888
labels: ${{ env.REPORT_LABEL }}
8989

90-
- name: Send Slack notification if workflow fails
91-
uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad
92-
if: ${{ failure() && env.FREEZE != 'true' }}
90+
- uses: ./.github/actions/slack-alert
9391
with:
94-
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
95-
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
96-
color: failure
97-
text: The last "Check Broken Docs Links in github/github" run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/check-broken-links-github-github.yml
92+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
93+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/check-for-spammy-issues.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,8 @@ jobs:
8080
} catch (error) {
8181
console.log(error);
8282
}
83+
84+
- uses: ./.github/actions/slack-alert
85+
with:
86+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
87+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/close-bad-repo-sync-prs.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ jobs:
6161
body: "Please leave this `repo-sync` branch to the robots!\n\nI'm going to close this pull request now, but feel free to open a new issue or ask any questions in [discussions](https://github.com/github/docs/discussions)!"
6262
})
6363
64-
- name: Send Slack notification if workflow fails
65-
uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad
66-
if: failure()
64+
- uses: ./.github/actions/slack-alert
6765
with:
68-
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
69-
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
70-
color: failure
71-
text: The last close-bad-repo-sync-prs run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions?query=Close+bad+repo-sync+PRs
66+
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
67+
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

0 commit comments

Comments
 (0)