Skip to content

Commit 14bcfd2

Browse files
committed
add promotions issue workflow
1 parent 76efded commit 14bcfd2

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Clean Promotion Checklist
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
clean-promotion-checklist:
12+
runs-on: ubuntu-latest
13+
if: contains(join(github.event.issue.labels.*.name, ','), 'promotions-workflow')
14+
steps:
15+
- name: Extract checked items and update issue body
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
const issue = context.payload.issue;
20+
const body = issue.body;
21+
22+
const lines = body.split('\n');
23+
const startIndex = lines.findIndex(line =>
24+
line.includes('✅ Acceptance Criteria') ||
25+
line.includes(':white_check_mark: Acceptance Criteria')
26+
);
27+
28+
if (startIndex === -1) {
29+
console.log("Acceptance Criteria section not found.");
30+
return;
31+
}
32+
33+
const headerLines = lines.slice(0, startIndex + 2); // Keep until checklist intro
34+
const checklistLines = lines.slice(startIndex + 2);
35+
36+
const keptLines = checklistLines.filter(line =>
37+
/\[\s*x\s*\]/i.test(line)
38+
);
39+
const normalized = keptLines.map(line =>
40+
line.replace(/\[\s*x\s*\]/i, '[x]')
41+
);
42+
const unChecked = normalized.map(line => line.replace('[x]', '[ ]'));
43+
44+
const newBody = [...headerLines, ...unChecked].join('\n');
45+
46+
await github.rest.issues.update({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
issue_number: issue.number,
50+
body: newBody
51+
});

0 commit comments

Comments
 (0)