-
Notifications
You must be signed in to change notification settings - Fork 13
79 lines (71 loc) · 2.56 KB
/
set-default-pr-values.yaml
File metadata and controls
79 lines (71 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
79
name: Set default values to PR
# Add the PR to the central project (status in project is set via workflow in project)
# Add the creator of the PR as assignee
# Add the next available milestone to the PR
on:
pull_request:
types:
- opened
permissions:
issues: write
pull-requests: write
jobs:
set-default-values:
runs-on: ubuntu-latest
steps:
- name: Add creator as assignee
if: ${{ github.actor != 'dependabot[bot]' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{github.repository}}/issues/${{github.event.number}}/assignees \
-f "assignees[]=${{github.actor}}"
- name: Add next milestone
uses: actions/github-script@v8
with:
script: |
const milestones = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
sort: "due_on",
direction: "asc"
})
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
milestone: milestones.data[0].number
});
- name: Set default labels
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/github-script@v8
env:
TITLE: ${{ github.event.pull_request.title }}
with:
script: |
const title = process.env.TITLE;
let defaultLabels = [];
if (title.startsWith("feat:")) {
defaultLabels.push("enhancement");
} else if (title.startsWith("fix:")) {
defaultLabels.push("bug");
} else if (title.startsWith("docs:")) {
defaultLabels.push("documentation");
} else if (title.startsWith("test:")) {
defaultLabels.push("test setup", "internal", "ignore-for-release");
} else if (title.startsWith("refactor:")) {
defaultLabels.push("internal", "ignore-for-release", "refactoring");
} else {
defaultLabels.push("internal", "ignore-for-release");
}
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: defaultLabels
});