Repo Sync Stalls #713
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- 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 }} |