-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
44 lines (36 loc) · 1.53 KB
/
auto-milestone.yaml
File metadata and controls
44 lines (36 loc) · 1.53 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
name: Auto-assign milestone
on:
issues:
types: [opened]
env:
MILESTONE_NAME: '4.x'
jobs:
assign-milestone:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Assign milestone
uses: actions/github-script@v8
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
// Pagination-safe fetch of open milestones
const milestones = await github.paginate(
github.rest.issues.listMilestones,
{ owner, repo, state: 'open', per_page: 100 }
);
const name = process.env.MILESTONE_NAME;
const target = milestones.find(m => m.title === name);
if (!target) {
core.warning(`Milestone '${name}' not found among open milestones.`);
return;
}
await github.rest.issues.update({
owner,
repo,
issue_number: context.issue.number,
milestone: target.number,
});
core.info(`Assigned milestone '${name}' (#${target.number}) to issue #${context.issue.number}.`);