-
Notifications
You must be signed in to change notification settings - Fork 6
67 lines (59 loc) · 2.4 KB
/
add-or-validate-labels.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Adds labels to pull requests based on the branch name. Labels are required by the "publish" workflow to determine
name: 'Validate PR labels'
on:
workflow_dispatch: # Lets you see what labels would be added, but doesn't actually add them because no PR triggered it
pull_request:
types:
- opened
- labeled
- unlabeled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-labels:
name: Validate PR labels
runs-on: ubuntu-latest
outputs:
VERSION_INSTRUCTION: ${{ steps.validate.outputs.VERSION_INSTRUCTION }}
steps:
- uses: actions/checkout@v3
- name: Validate that version bump labels are on the PR
id: validate
uses: ./.github/actions/validate-version-labels
with:
LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
upsert-pr-comment:
name: Upsert PR labels comment
if: always()
needs: validate-labels
runs-on: ubuntu-latest
steps:
- name: Build comment contents
id: bc
run: |
VERSION_INSTRUCTION=${{ needs.validate-labels.outputs.VERSION_INSTRUCTION }}
if [[ -z $VERSION_INSTRUCTION ]]; then
MESSAGE=":stop_sign: This PR needs labels to indicate how to increase the current package version in the automated workflows. Please add one of the following labels: \`none\`, \`patch\`, \`minor\`, or \`major\`."
elif [[ $VERSION_INSTRUCTION == none ]]; then
MESSAGE=":large_blue_circle: This PR has the \`none\` label set and it will not cause a version bump."
else
MESSAGE=":green_circle: This PR has valid version labels and will cause a \`$VERSION_INSTRUCTION\` bump."
fi
echo "MESSAGE=$MESSAGE" >> $GITHUB_OUTPUT
- name: Find previous comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: NPM Publishing labels
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### NPM Publishing labels :label:
${{ steps.bc.outputs.MESSAGE }}
edit-mode: replace