-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcontent-validation.yml
More file actions
116 lines (97 loc) · 3.48 KB
/
Copy pathcontent-validation.yml
File metadata and controls
116 lines (97 loc) · 3.48 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
111
112
113
114
115
116
name: Accessibility & Content Validation
# Validates markdown, links, and accessibility standards
# Runs on all PR updates so students get instant feedback
on:
pull_request:
types: [opened, edited, synchronize, reopened]
concurrency:
group: content-validation-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
issues: write
pull-requests: write
jobs:
validate-content:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install Python dependencies
run: |
pip install requests markupsafe
- name: Install Node dependencies
run: |
if [ -f package-lock.json ]; then
npm ci
elif [ -f package.json ]; then
npm install
else
echo "No package.json found; skipping npm install"
fi
- name: Check for broken links
id: links
run: |
python .github/scripts/check_links.py . || true
- name: Validate markdown structure
id: markdown
run: |
python .github/scripts/check_markdown.py . || true
- name: Validate accessibility
id: accessibility
run: |
python .github/scripts/check_accessibility.py . || true
- name: Post validation feedback
if: always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const { buildContentValidationComment } = require('./.github/scripts/build-content-validation-comment.js');
let feedback = { errors: [], warnings: [], accessibility: [] };
try {
if (fs.existsSync('validation-feedback.json')) {
const newFeedback = JSON.parse(fs.readFileSync('validation-feedback.json', 'utf8'));
feedback = { ...feedback, ...newFeedback };
}
} catch (error) {
console.error('Error reading validation feedback:', error);
}
const comment = buildContentValidationComment(feedback);
try {
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number
});
const botComment = comments.find(c =>
c.user.type === 'Bot' &&
c.body.includes('Content Validation Report')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: comment
});
}
} catch (error) {
console.error('Error posting comment:', error);
}