1
+ name : Update Roadmap Released
2
+
3
+ on :
4
+ pull_request :
5
+ types : [closed]
6
+ workflow_dispatch :
7
+ schedule :
8
+ - cron : " 0 */6 * * *"
9
+
10
+ permissions :
11
+ pull-requests : read
12
+ contents : read
13
+ issues : write
14
+
15
+ jobs :
16
+ update :
17
+ runs-on : ubuntu-latest
18
+ steps :
19
+ - name : Update "Released" section with last 10 closed PRs
20
+ uses : actions/github-script@v7
21
+ env :
22
+ ROADMAP_ISSUE_NUMBER : " 459"
23
+ with :
24
+ script : |
25
+ const issue_number = parseInt(process.env.ROADMAP_ISSUE_NUMBER, 10);
26
+ const {owner, repo} = context.repo;
27
+
28
+ // Fetch more than 10, then sort by closed_at to be precise
29
+ const batchSize = 50;
30
+ const { data: prBatch } = await github.rest.pulls.list({
31
+ owner,
32
+ repo,
33
+ state: "closed",
34
+ per_page: batchSize,
35
+ sort: "updated",
36
+ direction: "desc"
37
+ });
38
+
39
+ const last10 = prBatch
40
+ .filter(pr => pr.closed_at) // closed PRs
41
+ .sort((a, b) => new Date(b.closed_at) - new Date(a.closed_at))
42
+ .slice(0, 10);
43
+
44
+ const list = last10.map(pr => `- #${pr.number}`).join("\n");
45
+
46
+ const start = "<!-- RELEASED:START -->";
47
+ const end = "<!-- RELEASED:END -->";
48
+
49
+ const closedUrl = `https://github.com/${owner}/${repo}/pulls?q=is%3Apr+is%3Aclosed`;
50
+ const replacementBlock = [
51
+ start,
52
+ "",
53
+ `10 most recent [closed PRs](${closedUrl}):`,
54
+ "",
55
+ list,
56
+ "",
57
+ end
58
+ ].join("\n");
59
+
60
+ const { data: issue } = await github.rest.issues.get({ owner, repo, issue_number });
61
+ let body = issue.body || "";
62
+
63
+ if (body.includes(start) && body.includes(end)) {
64
+ const pattern = new RegExp(`${start}[\\s\\S]*?${end}`);
65
+ body = body.replace(pattern, replacementBlock);
66
+ } else {
67
+ core.setFailed('Missing RELEASED markers in roadmap issue body. Please add <!-- RELEASED:START --> and <!-- RELEASED:END --> to the issue.');
68
+ return;
69
+ }
70
+
71
+ await github.rest.issues.update({
72
+ owner,
73
+ repo,
74
+ issue_number,
75
+ body
76
+ });
0 commit comments