-
Notifications
You must be signed in to change notification settings - Fork 55
78 lines (66 loc) · 2.85 KB
/
Copy pathdocs-check.yml
File metadata and controls
78 lines (66 loc) · 2.85 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Docs Update Check
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
branches: [main]
permissions:
contents: read
pull-requests: read
jobs:
check-docs:
# Skip dependabot PRs
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Check for undocumented CLI changes
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const SKIP_LABEL = 'docs-not-needed';
// Check if the skip label is present
const labels = context.payload.pull_request.labels.map(l => l.name);
if (labels.includes(SKIP_LABEL)) {
console.log(`"${SKIP_LABEL}" label found — skipping docs check.`);
return;
}
// Get changed files
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});
const changedPaths = files.map(f => f.filename);
// Patterns that indicate user-facing CLI changes
const cliChangePatterns = [
/^docs\/cli-schema\.json$/,
/^src\/winapp-CLI\/.*\/Commands\//,
/^src\/winapp-npm\/src\/cli\.ts$/,
/^winapp\.example\.yaml$/,
];
// Check if any CLI-related files changed
const cliChanges = changedPaths.filter(p =>
cliChangePatterns.some(pattern => pattern.test(p))
);
if (cliChanges.length === 0) {
console.log('No CLI-related changes detected — docs check not applicable.');
return;
}
// Check if any docs were updated (excluding cli-schema.json which is auto-generated)
const docsChanges = changedPaths.filter(p =>
(p.startsWith('docs/') && p !== 'docs/cli-schema.json') ||
p === 'README.md'
);
if (docsChanges.length > 0) {
console.log('CLI changes detected and docs were updated:');
console.log(' CLI changes:', cliChanges.join(', '));
console.log(' Docs changes:', docsChanges.join(', '));
return;
}
// CLI changed but no docs updated — fail the check
core.setFailed(
`This PR changes CLI commands or options but no documentation was updated.\n\n` +
`Changed CLI files:\n${cliChanges.map(f => ` - ${f}`).join('\n')}\n\n` +
`Please update the relevant docs under \`docs/\`, or add the \`${SKIP_LABEL}\` label ` +
`if no documentation changes are needed (e.g., internal refactor, bug fix with no user-facing impact).`
);