Crawl API docs links #124
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: Crawl API docs links | |
# **What it does**: Regularly audits API links in our documentation. | |
# **Why we have it**: It's too burdensome to check on every commit like we do for internal links. | |
# **Who does it impact**: PCX team | |
on: | |
schedule: | |
- cron: "0 0 * * 0" # Run at 00:00 UTC every Sunday | |
workflow_dispatch: | |
jobs: | |
compile: | |
name: Compiles | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- uses: actions/cache@v4 | |
id: npm-cache | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm install @actions/core@1 puppeteer@22 | |
- name: Run API docs link checker | |
id: check-api-links | |
run: npm run crawl-api-links | |
- name: Create issue | |
env: | |
EXPORTED_VARIABLE: ${{ steps.check-api-links.outputs.brokenLinks }} | |
if: env.EXPORTED_VARIABLE | |
run: | | |
# Create the issue and reference the exported variable | |
curl --silent -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/repos/cloudflare/cloudflare-docs/issues" \ | |
-d "{\"title\": \"Broken API docs links\", \"body\": \"The following API doc links are broken: ${EXPORTED_VARIABLE}\", \"assignees\": [\"haleycode\"]}" |