Skip to content

Commit a64b9d5

Browse files
committed
docs(github-docs): add docs watch workflow
1 parent 1b5f891 commit a64b9d5

6 files changed

Lines changed: 862 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Description
2+
# Checks designated GitHub documentation pages for content changes and files an issue when detected.
3+
4+
name: GitHub Docs Watch
5+
6+
on:
7+
# Run every 14 days at 09:00 UTC and allow manual runs for verification.
8+
schedule:
9+
- cron: '0 9 */14 * *'
10+
workflow_dispatch:
11+
12+
permissions:
13+
# Read repo contents and open issues on detected changes.
14+
contents: read
15+
issues: write
16+
17+
jobs:
18+
check:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
# Checkout repository contents for local hashes and metadata.
23+
- uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20.x
29+
30+
- name: Check documentation hashes
31+
id: check
32+
run: node scripts/check-github-docs.mjs --output docs/github-documentation/docs-check.json --write-summary
33+
34+
- name: Create issue if docs changed
35+
# Avoid opening duplicate issues by title when changes are detected.
36+
if: steps.check.outputs.changed == 'true'
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
const fs = require('fs');
41+
const data = JSON.parse(fs.readFileSync('docs/github-documentation/docs-check.json', 'utf8'));
42+
const changed = data.results.filter((item) => item.changed);
43+
44+
const title = 'GitHub documentation change detected';
45+
const { owner, repo } = context.repo;
46+
47+
const existing = await github.rest.issues.listForRepo({
48+
owner,
49+
repo,
50+
state: 'open',
51+
per_page: 100,
52+
});
53+
54+
if (existing.data.some((issue) => issue.title === title)) {
55+
console.log('Existing issue found; skipping creation.');
56+
return;
57+
}
58+
59+
const lines = [
60+
'The scheduled documentation check detected changes in these files:',
61+
'',
62+
];
63+
64+
for (const item of changed) {
65+
lines.push(`- ${item.file}`);
66+
lines.push(` - redirect: ${item.redirect_link}`);
67+
lines.push(` - expected: ${item.expected_hash ?? 'missing'}`);
68+
lines.push(` - actual: ${item.actual_hash}`);
69+
lines.push('');
70+
}
71+
72+
lines.push(
73+
`Run: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
74+
);
75+
76+
await github.rest.issues.create({
77+
owner,
78+
repo,
79+
title,
80+
body: lines.join('\n'),
81+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"changed": false,
3+
"changed_count": 0,
4+
"results": [
5+
{
6+
"file": "docs/github-documentation/rate-limit.md",
7+
"redirect_link": "https://docs.github.com/api/article/body?pathname=/en/rest/rate-limit/rate-limit",
8+
"expected_hash": "eab796b16a014b82e54bd3bc27e37f3b0ea8fee2ff127c5c3930d0576f7d44d1",
9+
"actual_hash": "eab796b16a014b82e54bd3bc27e37f3b0ea8fee2ff127c5c3930d0576f7d44d1",
10+
"changed": false,
11+
"diff": null
12+
},
13+
{
14+
"file": "docs/github-documentation/rate-limits-for-the-rest-api.md",
15+
"redirect_link": "https://docs.github.com/api/article/body?pathname=/en/rest/using-the-rest-api/rate-limits-for-the-rest-api",
16+
"expected_hash": "1f5440f0777dc38c8ff65f28539c9ec28ea816bf7dcd671d51b23b8bb5bc4e7c",
17+
"actual_hash": "1f5440f0777dc38c8ff65f28539c9ec28ea816bf7dcd671d51b23b8bb5bc4e7c",
18+
"changed": false,
19+
"diff": null
20+
}
21+
]
22+
}

0 commit comments

Comments
 (0)