-
Notifications
You must be signed in to change notification settings - Fork 69
45 lines (40 loc) · 1.44 KB
/
check_labels.yml
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
name: Check Labels
# Every PR should have a label and some labels should include an update to the release notes
on:
pull_request:
branches-ignore:
- 'main'
types: [ synchronize, labeled, unlabeled ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
labels-check:
# https://github.com/actions/virtual-environments/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check PR labels
env:
ALL_PR_LABELS: toJson(github.event.pull_request.labels.*.name)
run: |
echo "$ALL_PR_LABELS"
all_pr_labels= $(jq -r '.[]' <<< $$ALL_PR_LABELS )
if [[ "${all_pr_labels[@]}" =~ 'Breaking change' || "${all_pr_labels[@]}" =~ 'Feature' || "${all_pr_labels[@]}" =~ 'Fix' ]]
then
git fetch origin develop --depth 1
if [ -n "$(git diff origin/develop RELEASE_NOTES.md)" ]
then
echo "RELEASE_NOTES.md was updated"
exit 0
else
echo "::error::Add release notes for your PR by updating RELEASE_NOTES.md"
exit 1
fi
elif [[ "${all_pr_labels[@]}" =~ 'Dependencies' || "${all_pr_labels[@]}" =~ 'Chore' ]]
then
echo "No extra actions needed for used labels"
exit 0
fi
echo "::error::You must add a valid label to this PR"
exit 1