Skip to content

Repo Sync Stalls #14981

Repo Sync Stalls

Repo Sync Stalls #14981

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: '20 */2 * * *' # Run every 2nd hour at 20 minutes after
permissions:
contents: read
pull-requests: read
jobs:
repo-sync-stalls:
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
runs-on: ubuntu-latest
steps:
- name: Check if repo sync is stalled
uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0
with:
script: |
let pulls;
const owner = context.repo.owner
const repo = context.repo.repo
try {
pulls = await github.rest.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: Check out repo
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}