-
-
Notifications
You must be signed in to change notification settings - Fork 620
78 lines (70 loc) · 2.56 KB
/
pr_management.yml
File metadata and controls
78 lines (70 loc) · 2.56 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
name: PR Management
on:
pull_request_target:
types: [opened, reopened, synchronize, closed]
permissions:
contents: read
jobs:
manage_pr:
runs-on: ubuntu-latest
timeout-minutes: 10
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const labels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
if (labels.data.every(label => label.name != "Waiting On Author")) {
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # 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@ed597411d8f924073f98dfc5c65a23a2325f34cd # 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
});
}