-
Notifications
You must be signed in to change notification settings - Fork 111
42 lines (35 loc) · 1.28 KB
/
associate_milestone_pr.yml
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
name: Associate Milestone(PR)
on:
pull_request_target:
types: [ opened ]
jobs:
associate-milestone-PR:
runs-on: ubuntu-latest
env:
MILESTONE_TITLE: ${{ secrets.MILESTONE_TITLE }}
steps:
- name: Associate Milestone
uses: actions/github-script@v7
with:
github-token: ${{ secrets.BOT_TOKEN_1 }}
script: |
const { owner, repo } = context.repo;
const issueNumber = context.issue.number;
const milestoneTitle = process.env.MILESTONE_TITLE;
// Get the milestone ID by title
const milestones = await github.rest.issues.listMilestones({
owner,
repo,
});
const milestone = milestones.data.find(m => m.title === milestoneTitle);
if (!milestone) {
throw new Error(`Milestone with title "${milestoneTitle}" not found`);
}
// Associate the issue with the milestone
await github.rest.issues.update({
owner,
repo,
issue_number: issueNumber,
milestone: milestone.number,
});
console.log(`Associated issue #${issueNumber} with milestone "${milestoneTitle}"`);