-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (38 loc) · 1.57 KB
/
story-review.yml
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
name: Story Issue Checkbox
on:
issues:
types: [ edited ]
permissions:
issues: write
jobs:
update-checkbox:
runs-on: ubuntu-latest
steps:
- name: Checkboxes
uses: actions/github-script@v6
with:
script: |
const checkboxes = ["<!-- check-ba -->BA Review", "<!-- check-dev -->DEV Review", "<!-- check-po -->PO Review"];
const issueBody= context.payload.issue.body
const oldIssueBody = context.payload.changes.body.from
const username = context.actor;
for(const checkbox of checkboxes){
if(issueBody.includes(`- [x] ${checkbox}`) && oldIssueBody.includes(`- [ ] ${checkbox}`)){
const updatedBody = issueBody.replace(`- [x] ${checkbox}`, `- [x] ${checkbox} (@${username})`);
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: updatedBody
});
} else if(issueBody.includes(`- [ ] ${checkbox}`) && oldIssueBody.includes(`- [x] ${checkbox}`)){
const regex = new RegExp(`- \\[ \\] ${checkbox} \\(@[^)]+\\)`, 'g');
const updatedBody = issueBody.replace(regex, `- [ ] ${checkbox}`);
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: updatedBody
});
}
}