forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) 路 1.58 KB
/
Copy pathissue-quality-gate.yml
File metadata and controls
55 lines (47 loc) 路 1.58 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
name: Issue Quality Gate
on:
issues:
types: [opened, edited]
jobs:
gate:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v7
id: validate
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const issueNum = context.issue.number;
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNum,
});
const body = issue.body || '';
const title = issue.title || '';
console.log(`=== Issue Quality Gate: #${issueNum} ===`);
let HAS_AC = false;
let HAS_CHECKBOX = false;
if (/acceptance criteria|AC|楠屾敹鏍囧噯|MANDATORY/i.test(body)) {
HAS_AC = true;
console.log(' AC section found');
}
if (/\[ \]|\[x\]|\[X\]/i.test(body)) {
HAS_CHECKBOX = true;
console.log(' Checkbox list found');
}
let labels = [];
if (!HAS_AC || !HAS_CHECKBOX) labels.push('needs-ac');
if (HAS_AC && HAS_CHECKBOX) labels.push('ready');
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNum,
labels: labels,
});
console.log(`Labels applied: ${labels.join(', ')}`);
}