-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (84 loc) · 2.83 KB
/
Copy pathsync-roadmap-issues.yml
File metadata and controls
100 lines (84 loc) · 2.83 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Sync Roadmap Issues
on:
workflow_dispatch:
push:
paths:
- github-roadmap-issues.json
- .github/workflows/sync-roadmap-issues.yml
permissions:
contents: read
issues: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Missing Roadmap Issues
uses: actions/github-script@v7
with:
script: |
const fs = require('node:fs');
const path = require('node:path');
const issuesPath = path.join(process.env.GITHUB_WORKSPACE, 'github-roadmap-issues.json');
const payload = JSON.parse(fs.readFileSync(issuesPath, 'utf8'));
const owner = context.repo.owner;
const repo = context.repo.repo;
const labelColors = {
'roadmap/ws1': '0e8a16',
'roadmap/ws2': '1d76db',
'roadmap/ws3': 'b60205',
'roadmap/ws4': '5319e7',
'roadmap/ws5': 'fbca04',
'roadmap/ws6': '0052cc',
'status/partial': 'fbca04',
'status/missing': 'd93f0b',
'priority/high': 'b60205',
'priority/medium': 'fbca04',
'priority/low': '0e8a16',
'docs-required': '0052cc',
};
const ensureLabel = async (name) => {
try {
await github.rest.issues.getLabel({ owner, repo, name });
} catch (error) {
if (error.status !== 404) throw error;
await github.rest.issues.createLabel({
owner,
repo,
name,
color: labelColors[name] || '6e7781',
});
}
};
const existingIssues = await github.paginate(github.rest.issues.listForRepo, {
owner,
repo,
state: 'all',
per_page: 100,
});
const existingTitleSet = new Set(
existingIssues
.filter((issue) => !issue.pull_request)
.map((issue) => issue.title)
);
let created = 0;
let skipped = 0;
for (const item of payload) {
if (existingTitleSet.has(item.title)) {
skipped += 1;
continue;
}
for (const label of item.labels) {
await ensureLabel(label);
}
await github.rest.issues.create({
owner,
repo,
title: item.title,
body: item.body,
labels: item.labels,
});
created += 1;
}
core.notice(`Roadmap issue sync complete. Created: ${created}, Skipped existing: ${skipped}`);