-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (38 loc) · 1.37 KB
/
pr.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
name: Validate PR format
on:
pull_request:
types:
- opened
- synchronize
- edited
- reopened
jobs:
validate-pr-format:
name: Title and description
runs-on: ubuntu-latest
steps:
- name: Check if it's a Dependabot PR
id: dependabot-check
run: |
if [[ "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ]]; then
echo "info: Skipping validation for Dependabot PR."
echo "::set-output name=skip_validation::true"
else
echo "::set-output name=skip_validation::false"
fi
- name: Check PR title format
if: steps.dependabot-check.outputs.skip_validation != 'true'
run: |
PR_TITLE_REGEX="^PR-[0-9]+: .+"
if [[ ! "${{ github.event.pull_request.title }}" =~ $PR_TITLE_REGEX ]]; then
echo "error: Invalid PR title format. Please use 'PR-XXX: Your title'."
exit 1
fi
- name: Check PR description format
if: steps.dependabot-check.outputs.skip_validation != 'true'
run: |
# Check if the description contains a list of changes (e.g., using '* ' to indicate list items)
if ! grep -q '^\s*\*\s' <<< "${{ github.event.pull_request.body }}"; then
echo "error: PR description should contain a list of changes."
exit 1
fi