1
0
mirror of synced 2025-12-30 12:02:01 -05:00

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>
This commit is contained in:
Chiedo John
2020-12-09 10:29:22 -05:00
committed by GitHub
parent 0e9bedbc48
commit aae3c4e6de

58
.github/workflows/repo-sync-stalls.yml vendored Normal file
View File

@@ -0,0 +1,58 @@
name: Repo Sync Stalls
on:
workflow_dispatch:
schedule:
- cron: '*/30 * * * *'
jobs:
check-freezer:
name: Check for deployment freezes
runs-on: ubuntu-latest
steps:
- name: Exit if repo is frozen
if: ${{ env.FREEZE == 'true' }}
run: |
echo 'The repo is currently frozen! Exiting this workflow.'
exit 1 # prevents further steps from running
repo-sync-stalls:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
ref: repo-sync
- name: Check if repo sync is stalled
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
with:
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
script: |
let pulls;
const owner = context.payload.repository.owner.login
const repo = context.payload.repository.name
try {
pulls = await github.pulls.list({
owner: owner,
repo: repo,
head: `${owner}:repo-sync`,
state: 'open'
});
} catch(err) {
throw err
return
}
pulls.data.forEach(pr => {
const timeDelta = Date.now() - Date.parse(pr.created_at);
const minutesOpen = timeDelta / 1000 / 60;
if (minutesOpen > 30) {
core.setFailed('Repo sync appears to be stalled')
}
})
- name: Send Slack notification if workflow fails
uses: rtCamp/action-slack-notify@e17352feaf9aee300bf0ebc1dfbf467d80438815
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }}
SLACK_USERNAME: docs-repo-sync
SLACK_ICON_EMOJI: ':ohno:'
SLACK_COLOR: '#B90E0A' # Crimson
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