Skip to content

Commit 2daf1ba

Browse files
authored
labeler tweaks (#2617)
1 parent f7eb10c commit 2daf1ba

File tree

4 files changed

+44
-35
lines changed

4 files changed

+44
-35
lines changed

.github/labeler.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010

1111
# Add 'enhancement' label to any PR where the head branch name contains `feat`
1212
enhancement:
13-
- head-branch: ['feat']
13+
- head-branch: [feat, Feat, FEAT]
1414

1515
# Add 'repo' label to any PR where the head branch name contains `repo`
1616
# or files in the .github dir
1717
repo:
1818
- any:
19-
- head-branch: ['repo']
19+
- head-branch: [repo, Repo]
2020
- changed-files:
21-
- any-glob-to-any-file: '.github'
21+
- any-glob-to-any-file: .github
2222

2323
# Add 'bug' label to any PR where the head branch name contains `fix` or `bug`
2424
bugfix:
25-
- head-branch: ['fix', 'bug']
25+
- head-branch: [fix, bug, Fix, FIX, Bug, BUG]
2626

2727
# our fallback - bug except repo, feat, or automated pipelines
2828
# bug_fallthrough:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check PR Labels
2+
3+
on:
4+
pull_request:
5+
types: [edited, labeled]
6+
7+
permissions:
8+
pull-requests: read
9+
contents: read
10+
11+
jobs:
12+
check-label:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check for PR labels
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
const labels = context.payload.pull_request.labels.map(label => label.name);
20+
const requiredLabels = ['bugfix', 'enhancement', 'automation', 'dependencies', 'repo', 'release'];
21+
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label));
22+
console.log(labels);
23+
if (!hasRequiredLabel) {
24+
core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`);
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Pull Request Labeler"
2+
on:
3+
- pull_request_target
4+
# Do not execute arbitary code on this workflow.
5+
# See warnings at https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target
6+
7+
jobs:
8+
labeler:
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- id: label-the-PR
15+
uses: actions/labeler@v5

.github/workflows/pull-request.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,3 @@ jobs:
5656
}
5757
exit_on_result "build_and_detekt" "${{ needs.build_and_detekt.result }}"
5858
exit_on_result "androidTest" "${{ needs.androidTest.result }}"
59-
60-
labeler:
61-
permissions:
62-
contents: read
63-
pull-requests: write
64-
runs-on: ubuntu-latest
65-
steps:
66-
- id: label-the-PR
67-
uses: actions/labeler@v5
68-
continue-on-error: true
69-
70-
check-label:
71-
runs-on: ubuntu-latest
72-
needs:
73-
[
74-
check-workflow-status,
75-
labeler
76-
]
77-
if: always()
78-
steps:
79-
- name: Check for PR labels
80-
uses: actions/github-script@v7
81-
with:
82-
script: |
83-
const labels = context.payload.pull_request.labels.map(label => label.name);
84-
const requiredLabels = ['bugfix', 'enhancement', 'automation', 'dependencies', 'repo', 'release'];
85-
const hasRequiredLabel = labels.some(label => requiredLabels.includes(label));
86-
console.log(labels);
87-
if (!hasRequiredLabel) {
88-
core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`);
89-
}

0 commit comments

Comments
 (0)