forked from cloudflare/cloudflare-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.75 KB
/
api-links-crawl.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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\": [\"kodster28\", \"haleycode\"]}"