-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.53 KB
/
commit-check.yml
File metadata and controls
49 lines (41 loc) · 1.53 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
47
48
49
name: Conventional Commit Check for PR Title
on:
workflow_call:
jobs:
commit-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Check for commitlint config and install dependencies
id: commitlint-config
run: |
if [ -f .commitlintrc.json ] || [ -f .commitlintrc.js ] || [ -f .commitlintrc.yml ] || [ -f .commitlintrc.yaml ] || grep -q '"commitlint"' "package.json" 2>/dev/null; then
echo "has-config=true" >> $GITHUB_OUTPUT
else
echo "has-config=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies if config exists
if: steps.commitlint-config.outputs.has-config == 'true'
run: |
bun i -g @commitlint/cli
bun i
- name: Install commitlint globally if no config
if: steps.commitlint-config.outputs.has-config == 'false'
run: |
bun i -g @commitlint/cli
bun i -D @commitlint/config-conventional
- name: Create commitlint config if missing
if: steps.commitlint-config.outputs.has-config == 'false'
run: |
echo "extends:" > .commitlintrc.yml
echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml
- name: Check PR title
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo "$PR_TITLE" | commitlint