Skip to content

Check Broken Docs Links in github/github #11

Check Broken Docs Links in github/github

Check Broken Docs Links in github/github #11

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
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_PAT_WRITEORG_PROJECT }}
REPORT_AUTHOR: docs-bot
REPORT_LABEL: github github broken link report
REPORT_REPOSITORY: github/docs-content
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
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.DOCS_BOT_PAT_READPUBLICKEY }}
- name: Build server
run: npm run build
- name: Start server in the background
env:
NODE_ENV: production
PORT: 4000
ENABLED_LANGUAGES: en
run: |
npm run start &
sleep 5
curl --retry-connrefused --retry 3 -I http://localhost:4000/
- name: Run broken github/github link check
run: |
npm run check-github-github-links -- 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') != '' }}
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') != '' }}
id: github-github-broken-link-report
uses: peter-evans/create-issue-from-file@24452a72d85239eacf1468b0f1982a9f3fec4c94
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 }}
- 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 }}