-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (40 loc) · 1.22 KB
/
label-prs.yaml
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
on:
pull_request_target:
types:
- opened
- reopened
name: Label PRs with `patch` by default
jobs:
get-labels:
name: Get PR labels
runs-on: ubuntu-latest
if: >
! startsWith(github.event.pull_request.head.ref, 'release/')
outputs:
labels: ${{ steps.get-labels.outputs.labels }}
steps:
- name: Get PR labels from GitHub API
id: get-labels
env:
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LABELS=$(gh api "repos/$REPO/issues/$NUMBER/labels")
echo "PR #$NUMBER is labeled with: $LABELS"
echo "labels=$LABELS" >> "$GITHUB_OUTPUT"
label:
name: Label PR with `patch`
needs:
- get-labels
if: >
! ( contains(fromJSON(needs.get-labels.outputs.labels).*.name, 'release')
|| contains(fromJSON(needs.get-labels.outputs.labels).*.name, 'minor')
|| contains(fromJSON(needs.get-labels.outputs.labels).*.name, 'major')
)
runs-on: ubuntu-latest
steps:
- name: Label PR with `patch`
uses: actions/labeler@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}