-
Notifications
You must be signed in to change notification settings - Fork 14
46 lines (44 loc) · 1.41 KB
/
Copy pathsemantic-prs.yaml
File metadata and controls
46 lines (44 loc) · 1.41 KB
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
---
name: "Semantic Lints PR"
on:
pull_request:
branches:
- main
- feat/more-attack-cov
types:
- opened
- edited
- synchronize
- reopened
workflow_dispatch:
inputs:
pr_number:
description: PR number to validate (used when dispatched manually)
required: true
type: string
permissions:
pull-requests: read
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- name: Validate conventional-commit title (pull_request)
if: github.event_name == 'pull_request'
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate conventional-commit title (workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ inputs.pr_number }}
run: |
title=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json title -q .title)
echo "PR #$PR_NUMBER title: $title"
if echo "$title" | grep -Eq '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([^)]+\))?!?: .+'; then
echo "Title matches conventional commit format."
else
echo "::error::PR title does not match conventional commit format"
exit 1
fi