-
Notifications
You must be signed in to change notification settings - Fork 9
61 lines (56 loc) · 1.88 KB
/
validate-pullrequest.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
name: Validate Pull Request
on:
pull_request_target:
types:
- opened
- edited
- reopened
- synchronize
jobs:
getChangedChart:
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
uses: ./.github/workflows/get-changed-chart.yaml
with:
pr_number: ${{ github.event.pull_request.number }}
validateCommits:
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
name: Validate commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Conventional commit check
uses: cocogitto/cocogitto-action@5ae166018d8265bb2df85c1eb521e86a17b61085 # v3
validateTitle:
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
name: Validate Title
runs-on: ubuntu-latest
needs: getChangedChart
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: Conventional commit check
uses: cocogitto/cocogitto-action@5ae166018d8265bb2df85c1eb521e86a17b61085 # v3
with:
check: false
- name: Verify that PR title is a conventional commit message
run: |
set -e
set -o pipefail
if ! cog verify "$PR_TITLE"; then
echo "PR title must be a conventional commit message" >&2
exit 1
fi
- name: Verify correct scope of PR title
if: ${{ needs.getChangedChart.outputs.found == 'true' }}
env:
CHANGED_CHART: ${{ needs.getChangedChart.outputs.chart }}
run: |
set -e
set -o pipefail
if ! cog verify "$PR_TITLE" 2>&1 | grep -Eq "^\s+Scope: $CHANGED_CHART(/.+|)\$"; then
echo "PR title must have scope '$CHANGED_CHART/\$subscope'" >&2
exit 1
fi