-
Notifications
You must be signed in to change notification settings - Fork 126
63 lines (54 loc) · 2.09 KB
/
Copy pathmainnet-checklist-sync.yml
File metadata and controls
63 lines (54 loc) · 2.09 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
name: Mainnet checklist sync
on:
issues:
types: [closed, reopened]
workflow_dispatch:
permissions:
contents: write
issues: read
pull-requests: read
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'docs/mainnet-launch-checklist.md';
const owner = context.repo.owner;
const repo = context.repo.repo;
let text = fs.readFileSync(path, 'utf8');
const issues = [...new Set([...text.matchAll(/issues\/(\d+)/g)].map((match) => Number(match[1])))];
const states = new Map();
for (const issue_number of issues) {
const { data } = await github.rest.issues.get({ owner, repo, issue_number });
states.set(issue_number, data.state);
}
const updated = text.split('\n').map((line) => {
if (!line.startsWith('|') || !line.includes('/issues/')) return line;
const issueMatch = line.match(/issues\/(\d+)/);
if (!issueMatch) return line;
const issueNumber = Number(issueMatch[1]);
const state = states.get(issueNumber);
if (!state) return line;
const cells = line.split('|');
if (cells.length < 6) return line;
cells[4] = ` ${state === 'closed' ? 'Complete' : 'In progress'} `;
return cells.join('|');
}).join('\n');
if (updated !== text) {
fs.writeFileSync(path, updated);
}
- name: Commit checklist update
run: |
if git diff --quiet -- docs/mainnet-launch-checklist.md; then
echo "No checklist changes."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add docs/mainnet-launch-checklist.md
git commit -m "Update mainnet checklist issue statuses"
git push