-
Notifications
You must be signed in to change notification settings - Fork 967
82 lines (72 loc) · 2.61 KB
/
pr-description.yml
File metadata and controls
82 lines (72 loc) · 2.61 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
name: 🧼 PR
on:
merge_group:
types:
- checks_requested
pull_request:
types:
- demilestoned
- edited
- milestoned
- opened
- synchronize
permissions: {}
jobs:
validate-description:
name: Validate Description
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'merge_group') {
// Ignore merge_group events
return;
}
const body = context.payload.pull_request.body || '';
const errors = [];
// Check for ## Description section
const descMatch = body.match(/^## Description:\s*\n([\s\S]*?)(?:^## |\Z)/m);
if (!descMatch || descMatch[1].trim().length < 20) {
errors.push('❌ Missing or short `## Description:` section.');
}
// Check all five boxes are checked
const requiredBoxes = [
/- \[x\] I have added screenshots for all UI updates/i,
/- \[x\] I process any text displayed to the user through translateText\(\) and I\'ve added it to the en\.json file/i,
/- \[x\] I have added relevant tests to the test directory/i,
/- \[x\] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced/i,
];
for (const box of requiredBoxes) {
if (!box.test(body)) {
errors.push('❌ One or more checklist items are not checked.');
break;
}
}
if (errors.length > 0) {
core.setFailed(errors.join('\n'));
} else {
console.log('✅ PR description and checklist look good.');
}
has-milestone:
name: Has Milestone
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'merge_group') {
// Ignore merge_group events
} else if (context.eventName === 'pull_request') {
// Get the pull request data
const milestone = context.payload.pull_request.milestone;
if (!milestone) {
core.setFailed('❌ Reviewer must assign a Milestone to this Pull request before merging.');
return;
}
console.log(`✅ Milestone found: ${milestone.title}`);
} else {
core.setFailed(`❌ Unknown event type ${context.eventName}.`);
}