Skip to content

Repo Sync Stalls

Repo Sync Stalls #720

name: Repo Sync Stalls
# **What it does**: This lets us know in Slack if repo-sync doesn't happen in a timely manner.
# **Why we have it**: We want repo-sync to keep the two repositories in sync with each other.
# **Who does it impact**: Open-source contributors, docs engineering.
on:
workflow_dispatch:
schedule:
- cron: '32 */2 * * *' # At minute 32 past every 2nd hour.
jobs:
repo-sync-stalls:
runs-on: ubuntu-latest
steps:
- if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
name: Check if repo sync is stalled
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
with:
github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
script: |
let pulls;
const owner = context.repo.owner
const repo = context.repo.repo
try {
pulls = await github.pulls.list({
owner: owner,
repo: repo,
head: `${owner}:repo-sync`,
state: 'open'
});
} catch(err) {
throw err
return
}
// Remove all pull requests that don't have the
// 'automated-reposync-pr' label
pulls.data = pulls.data.filter(pr =>
pr.labels.some(label => label.name === 'automated-reposync-pr')
)
// Search for pull requests that have been open too long
pulls.data.forEach(pr => {
const timeDelta = Date.now() - Date.parse(pr.created_at);
const minutesOpen = timeDelta / 1000 / 60;
if (minutesOpen > 180) {
core.setFailed('Repo sync appears to be stalled')
}
})
- name: Send Slack notification if workflow fails
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
if: ${{ failure() }}
with:
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
color: failure
text: Repo sync appears to be stalled for ${{github.repository}}. See https://github.com/${{github.repository}}/pulls?q=is%3Apr+is%3Aopen+label%3Aautomated-reposync-pr