forked from rdkcentral/firebolt-certification-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (32 loc) · 1.24 KB
/
pr-name-check.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
name: PR Name Check
on:
pull_request:
branches:
- 'dev'
types: [opened, edited, synchronize]
jobs:
check-pr-name:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Check PR title
run: |
if ! echo "${{ github.event.pull_request.title }}" | grep -Eq "^(feat|fix|BREAKING CHANGE)(\([^)]+\))?: "; then
echo 'FAIL_OUTPUT=Invalid PR title. It must start with feat: or fix: or BREAKING CHANGE: or feat(<DESCRIPTOR>): or fix(<DESCRIPTOR>): or BREAKING CHANGE(<DESCRIPTOR>):' >> $GITHUB_ENV
exit 1
fi
- name: Comment on PR
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_COMMENT: ${{ env.FAIL_OUTPUT }}
run: |
JSON_PAYLOAD=$(jq -n --arg body "$PR_COMMENT" '{"body": $body}')
echo "Generated JSON payload:"
echo "$JSON_PAYLOAD"
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"