-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (54 loc) · 2.02 KB
/
auto-label.yaml
File metadata and controls
67 lines (54 loc) · 2.02 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
## This action automatically handles PR labels with:
## - On PR opened, label based on pr-branch-labeler.yml
## - On PR closed, remove WIP or blocked labels
## - On commit added, if message contains 'wip' then add WIP label
name: Auto Label PR
on:
pull_request:
types:
- opened
- closed
- synchronize
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
auto-labels:
runs-on: ubuntu-latest
## Label PR on PR open based on branch name
steps:
- name: Label Initial PR
if: github.event.action == 'opened' # Only run the action when the PR was first opened
uses: ffittschen/pr-branch-labeler@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
## Remove labels on PR close
- name: Remove WIP Status Label
if: github.event.action == 'closed'
uses: actions-ecosystem/action-remove-labels@v1.3.0
continue-on-error: true
with:
github_token: ${{ secrets.github_token }}
labels: "status: WIP"
- name: Remove Blocked Status Label
if: github.event.action == 'closed'
uses: actions-ecosystem/action-remove-labels@v1.3.0
continue-on-error: true
with:
github_token: ${{ secrets.github_token }}
labels: "status: blocked"
## Actions to run when commit added to PR
# - Check if commit message has 'wip' and label if so
- uses: actions/checkout@v6.0.2
if: github.event.action == 'synchronize'
- name: Get Commit Message
if: github.event.action == 'synchronize'
id: commit
run: |
git fetch
git checkout ${{ github.event.pull_request.head.ref }}
echo "::set-output name=msg::$(git log -1 --pretty=format:'%s')"
- name: Add WIP Label if wip commit msg
if: startsWith(steps.commit.outputs.msg, 'wip') && github.event.action == 'synchronize'
uses: actions-ecosystem/action-add-labels@v1.1.3
with:
github_token: ${{ secrets.github_token }}
labels: "status: wip"