-
Notifications
You must be signed in to change notification settings - Fork 198
42 lines (37 loc) · 1.17 KB
/
Copy pathpr-title.yaml
File metadata and controls
42 lines (37 loc) · 1.17 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
name: PR Title
on:
workflow_dispatch:
inputs:
title:
description: PR title to validate
required: true
type: string
pull_request:
types:
- opened
- edited
- reopened
- ready_for_review
- synchronize
permissions: {}
jobs:
conventional-title:
runs-on: ubuntu-latest
steps:
- name: Validate PR title
env:
PR_TITLE: ${{ github.event_name == 'workflow_dispatch' && inputs.title || github.event.pull_request.title }}
run: |
set -euo pipefail
node <<'NODE'
const title = process.env.PR_TITLE ?? "";
const conventionalTitle = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([^)]+\))?!?: .+$/;
if (conventionalTitle.test(title)) {
console.log(`PR title is a Conventional Commit: ${title}`);
process.exit(0);
}
console.error("PR title must be a Conventional Commit title.");
console.error(`Got: ${title}`);
console.error("Expected examples: feat: add health check, fix(diff): close stale tabs, chore(release): 0.4.0");
process.exit(1);
NODE