Skip to content

Commit aae3c4e

Browse files
chiedoJamesMGreene
andauthored
Send a Slack notification when Repo Sync stalls (#16785)
* Check if Repo Sync has stalled Co-authored-by: Chiedo <chiedo@users.noreply.github.com> Co-authored-by: James M. Greene <JamesMGreene@github.com>
1 parent 0e9bedb commit aae3c4e

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Repo Sync Stalls
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '*/30 * * * *'
6+
jobs:
7+
check-freezer:
8+
name: Check for deployment freezes
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Exit if repo is frozen
12+
if: ${{ env.FREEZE == 'true' }}
13+
run: |
14+
echo 'The repo is currently frozen! Exiting this workflow.'
15+
exit 1 # prevents further steps from running
16+
repo-sync-stalls:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
20+
with:
21+
ref: repo-sync
22+
- name: Check if repo sync is stalled
23+
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
24+
with:
25+
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
26+
script: |
27+
let pulls;
28+
const owner = context.payload.repository.owner.login
29+
const repo = context.payload.repository.name
30+
try {
31+
pulls = await github.pulls.list({
32+
owner: owner,
33+
repo: repo,
34+
head: `${owner}:repo-sync`,
35+
state: 'open'
36+
});
37+
} catch(err) {
38+
throw err
39+
return
40+
}
41+
42+
pulls.data.forEach(pr => {
43+
const timeDelta = Date.now() - Date.parse(pr.created_at);
44+
const minutesOpen = timeDelta / 1000 / 60;
45+
46+
if (minutesOpen > 30) {
47+
core.setFailed('Repo sync appears to be stalled')
48+
}
49+
})
50+
- name: Send Slack notification if workflow fails
51+
uses: rtCamp/action-slack-notify@e17352feaf9aee300bf0ebc1dfbf467d80438815
52+
if: ${{ failure() }}
53+
env:
54+
SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }}
55+
SLACK_USERNAME: docs-repo-sync
56+
SLACK_ICON_EMOJI: ':ohno:'
57+
SLACK_COLOR: '#B90E0A' # Crimson
58+
SLACK_MESSAGE: Repo sync appears to be stalled for ${{github.repository}}. See https://github.com/${{github.repository}}/pulls?q=is%3Apr+is%3Aopen+repo+sync

0 commit comments

Comments
 (0)