Skip to content

Commit 88dbe0b

Browse files
authored
Implement workflow that adds new feature label to PRs automatically (#195)
* Add `new feature` checklist item * Create auto-label-pr-new-feature.yml * Fix grammar * Fix wording
1 parent 2bfd841 commit 88dbe0b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
> Replace this text with a brief description about **why** this PR is necessary. Be sure to provide context.
44
5+
- [ ] This PR includes a new feature.
6+
57
## Related issues and/or PRs
68

79
> Replace this text with links to any existing issues and/or PRs. Or, write `N/A` if no related issues and/or PRs exist.
810
911
## Changes made
1012

11-
> Replace this text with an outline the specific changes made in this pull request in the form of a bulleted list. Include relevant details, such as added features, bug fixes, code refactoring, or improvements.
13+
> Replace this text with an outline of the specific changes made in this pull request in the form of a bulleted list. Include relevant details, such as added features, bug fixes, code refactoring, or improvements.
1214
1315
<h2 id="checklist">Checklist</h2>
1416

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Add `new feature` label to PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
manage-feature-label:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Get PR body
12+
id: pr_body
13+
run: |
14+
echo "body<<EOF" >> $GITHUB_OUTPUT
15+
echo "${{ github.event.pull_request.body }}" >> $GITHUB_OUTPUT
16+
echo "EOF" >> $GITHUB_OUTPUT
17+
18+
- name: Add 'new feature' label if checked
19+
if: contains(steps.pr_body.outputs.body, '- [x] This PR includes a new feature.') || contains(steps.pr_body.outputs.body, '- [x] This PR includes a new feature.')
20+
uses: actions-ecosystem/action-add-labels@v1
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
labels: new feature
24+
25+
- name: Remove 'new feature' label if unchecked
26+
if: |
27+
!contains(steps.pr_body.outputs.body, '- [x] This PR includes a new feature.') &&
28+
!contains(steps.pr_body.outputs.body, '- [x] This PR includes a new feature.')
29+
uses: actions-ecosystem/action-remove-labels@v1
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
labels: new feature

0 commit comments

Comments
 (0)