-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.15 KB
/
Copy pathvalidate.yml
File metadata and controls
110 lines (94 loc) · 3.15 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Content Validation
#
# Runs `bun scripts/validate.ts` weekly and on push to main.
# - Errors (exit code 1): workflow fails
# - Warnings: opens/updates a rolling GitHub issue with label "content-refresh"
#
# The "content-refresh" label should be created in the repo with:
# description: "Automated content validation warnings from weekly CI"
# color: "fbca04" (yellow)
name: Content Validation
on:
schedule:
- cron: "0 9 * * 1" # Every Monday 9am UTC
push:
branches: [main]
workflow_dispatch: # Manual trigger
permissions:
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- name: Run validation
id: validate
run: |
bun scripts/validate.ts 2>&1 | tee /tmp/validate-output.txt
echo "output<<EOF" >> $GITHUB_OUTPUT
cat /tmp/validate-output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
continue-on-error: true
- name: Build site
run: bun run build
- name: Check for broken internal links
run: bun scripts/check-404s.ts
- name: Create or update issue
if: steps.validate.outcome == 'failure' || contains(steps.validate.outputs.output, 'WARN')
uses: actions/github-script@v7
with:
script: |
const title = 'Content refresh: terminfo.dev';
const output = process.env.VALIDATE_OUTPUT || '(no output captured)';
const body = [
'## Weekly Validation Report',
'',
`Run: ${new Date().toISOString()}`,
`Trigger: \`${context.eventName}\``,
'',
'```',
output,
'```',
'',
'---',
'*Auto-generated by [validate.yml](.github/workflows/validate.yml)*',
].join('\n');
const { owner, repo } = context.repo;
// Find existing open issue with the content-refresh label
const issues = await github.rest.issues.listForRepo({
owner,
repo,
state: 'open',
labels: 'content-refresh',
});
const existing = issues.data.find(i => i.title === title);
if (existing) {
await github.rest.issues.update({
owner,
repo,
issue_number: existing.number,
body,
});
core.info(`Updated issue #${existing.number}`);
} else {
const created = await github.rest.issues.create({
owner,
repo,
title,
body,
labels: ['content-refresh'],
});
core.info(`Created issue #${created.data.number}`);
}
env:
VALIDATE_OUTPUT: ${{ steps.validate.outputs.output }}
- name: Fail on errors
if: steps.validate.outcome == 'failure'
run: exit 1