-
Notifications
You must be signed in to change notification settings - Fork 416
57 lines (50 loc) · 1.65 KB
/
pr-name.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: pr-name
on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']
branches-ignore:
- "[0-9]+.[0-9]+"
jobs:
pr_name_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@v4
name: Install Node.js
with:
node-version: 16
- name: Install dependencies
run: |
npm install @commitlint/lint@18.6.1 @commitlint/load@18.6.1 @commitlint/config-conventional@18.6.2 @actions/core
- name: Lint PR name
uses: actions/github-script@v6.4.1
with:
script: |
const load = require('@commitlint/load').default;
const lint = require('@commitlint/lint').default;
const CONFIG = {
extends: ['./commitlint.config.js'],
};
const title = context.payload.pull_request.title;
core.info(`Linting: ${title}`);
load(CONFIG)
.then((opts) => {
lint(
title,
opts.rules,
opts.parserPreset ? {parserOpts: opts.parserPreset.parserOpts} : {}
).then((report) => {
report.warnings.forEach((warning) => {
core.warning(warning.message);
});
report.errors.forEach((error) => {
core.error(error.message);
});
if (!report.valid) {
core.setFailed("PR title linting failed");
}
});
});