Check Broken Docs Links in github/github #71
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: Check Broken Docs Links in github/github | |
# **What it does**: This checks for any broken docs.github.com links in github/github | |
# **Why we have it**: Make sure all docs in github/github are up to date | |
# **Who does it impact**: Docs engineering, people on GitHub | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '20 16 * * 1' # Run every Monday at 16:20 UTC / 8:20 PST | |
permissions: | |
contents: read | |
# **IMPORTANT:** Do not change the FREEZE environment variable set here! | |
# This workflow runs on a recurring basis. To temporarily disable it (e.g., | |
# during a docs deployment freeze), add an Actions Secret to the repo settings | |
# called `FREEZE` with a value of `true`. To re-enable workflow, simply | |
# delete that Secret from the repo settings. The environment variable here | |
# will duplicate that Secret's value for later evaluation. | |
env: | |
FREEZE: ${{ secrets.FREEZE }} | |
jobs: | |
check_github_github_links: | |
if: github.repository == 'github/docs-internal' | |
runs-on: ubuntu-latest | |
env: | |
# need to use a token from a user with access to github/github for this step | |
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_FR }} | |
FIRST_RESPONDER_PROJECT: Docs content first responder | |
REPORT_AUTHOR: docubot | |
REPORT_LABEL: github github broken link report | |
REPORT_REPOSITORY: github/docs-content | |
steps: | |
- if: ${{ env.FREEZE == 'true' }} | |
run: | | |
echo 'The repo is currently frozen! Exiting this workflow.' | |
exit 1 # prevents further steps from running | |
- name: Checkout | |
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 | |
with: | |
# To prevent issues with cloning early access content later | |
persist-credentials: 'false' | |
- uses: ./.github/actions/node-npm-setup | |
- uses: ./.github/actions/get-docs-early-access | |
with: | |
token: ${{ secrets.DOCUBOT_REPO_PAT }} | |
- name: Build server | |
run: npm run build | |
- name: Start server in the background | |
env: | |
NODE_ENV: production | |
PORT: 4000 | |
ENABLED_LANGUAGES: en | |
run: | | |
node server.js & | |
sleep 5 | |
curl --retry-connrefused --retry 3 -I http://localhost:4000/ | |
- name: Run broken github/github link check | |
run: | | |
script/check-github-github-links.js broken_github_github_links.md | |
- name: Get title for issue | |
# If the file 'broken_github_github_links.md' got created, | |
# the hash of it will not be an empty string. That means if found | |
# broken links, we want to create an issue. | |
if: ${{ hashFiles('broken_github_github_links.md') != '' && env.FREEZE != 'true' }} | |
id: check | |
run: echo "title=$(head -1 broken_github_github_links.md)" >> $GITHUB_OUTPUT | |
- name: Create issue from file | |
if: ${{ hashFiles('broken_github_github_links.md') != '' && env.FREEZE != 'true' }} | |
id: github-github-broken-link-report | |
uses: peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f | |
with: | |
token: ${{ env.GITHUB_TOKEN }} | |
title: ${{ steps.check.outputs.title }} | |
content-filepath: ./broken_github_github_links.md | |
repository: ${{ env.REPORT_REPOSITORY }} | |
labels: ${{ env.REPORT_LABEL }} | |
- name: Send Slack notification if workflow fails | |
uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad | |
if: ${{ failure() && env.FREEZE != 'true' }} | |
with: | |
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} | |
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} | |
color: failure | |
text: The last "Check Broken Docs Links in github/github" run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/check-broken-links-github-github.yml |