-
-
Notifications
You must be signed in to change notification settings - Fork 623
65 lines (60 loc) · 2.06 KB
/
pr_management.yml
File metadata and controls
65 lines (60 loc) · 2.06 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
name: PR Management
on:
pull_request_target:
types: [opened, reopened, synchronize, closed]
jobs:
manage_pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Auto Add Label
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize'
uses: actions/github-script@v8
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Waiting On Review']
})
- name: Auto Remove Label
if: github.event.action == 'closed'
uses: actions/github-script@v8
continue-on-error: true
with:
script: |
try {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Waiting On Review'
});
} catch (error) {
console.log('Label "Waiting On Review" not found or could not be removed.');
}
- name: Auto Assign Milestone
if: github.event.action == 'opened'
uses: actions/github-script@v8
with:
script: |
// Fetch open milestones and assign the closest one
const { data: milestones } = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
sort: 'due_on',
direction: 'asc'
});
if (milestones.length > 0) {
const latestMilestone = milestones[0];
await github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
milestone: latestMilestone.number
});
}