Skip to content

Commit 668a387

Browse files
authored
Merge pull request #23 from ergebnis/feature/triage
Enhancement: Add triage workflow
2 parents 78ffb13 + 029ab63 commit 668a387

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ We are using [GitHub Actions](https://github.com/features/actions) as a continuo
55
For details, take a look at the following workflow configuration files:
66

77
- [`workflows/integrate.yaml`](workflows/integrate.yaml)
8+
- [`workflows/triage.yaml`](workflows/triage.yaml)
89

910
## Coding Standards
1011

.github/workflows/triage.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# https://docs.github.com/en/actions
2+
3+
name: "Triage"
4+
5+
on: # yamllint disable-line rule:truthy
6+
pull_request:
7+
types:
8+
- "opened"
9+
10+
jobs:
11+
label:
12+
name: "Label"
13+
14+
runs-on: "ubuntu-latest"
15+
16+
steps:
17+
- name: "Add labels based on branch name"
18+
uses: "actions/github-script@v2.0.0"
19+
with:
20+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
21+
script: |
22+
const branchPrefixLabels = {
23+
feature: "enhancement",
24+
fix: "bug",
25+
}
26+
27+
const pullRequest = context.payload.pull_request
28+
const repository = context.repo
29+
30+
const branchName = pullRequest.head.ref
31+
32+
const matches = branchName.match(new RegExp('^([^/]+)\/'));
33+
34+
if (matches instanceof Array && branchPrefixLabels.hasOwnProperty(matches[1])) {
35+
const label = branchPrefixLabels[matches[1]]
36+
37+
github.issues.addLabels({
38+
issue_number: pullRequest.number,
39+
labels: [
40+
label
41+
],
42+
owner: repository.owner,
43+
repo: repository.repo,
44+
});
45+
}

0 commit comments

Comments
 (0)