Skip to content

Commit 8691fdf

Browse files
authored
chore: commitlint only the Pull Request HEAD (#4983)
we only want the first commit to be linted
1 parent b0730bb commit 8691fdf

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.commitlintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"defaultIgnores": true,
3-
"parserPreset": "conventional-changelog-conventionalcommits",
3+
"extends": "@commitlint/config-conventional",
44
"rules": {
55
"scope-enum": [
66
2,

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,24 @@ env:
1111

1212
jobs:
1313
commitlint:
14+
if: github.event_name == 'pull_request'
15+
env:
16+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1417
runs-on: ubuntu-latest
1518
steps:
1619
- uses: actions/checkout@v3
1720
with:
1821
fetch-depth: 0
19-
configFile: .commitlintrc
20-
- uses: wagoid/commitlint-github-action@v5
22+
- name: Run commitlint
23+
run: |
24+
commit=$(gh api \
25+
-H "Accept: application/vnd.github+json" \
26+
/repos/${{ github.repository }}/pulls/${{github.event.number}}/commits \
27+
| jq -r '.[0].commit.message')
28+
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
29+
echo '{}' > package.json
30+
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
31+
echo $commit | ./node_modules/.bin/commitlint -g .commitlintrc
2132
php-cs-fixer:
2233
name: PHP-cs-fixer (PHP ${{ matrix.php }})
2334
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)