Skip to content

Commit 40132c0

Browse files
committed
ci: rate limiting for commitlint
1 parent 6e4e46b commit 40132c0

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: CI
22

33
on:
44
push:
5-
pull_request:
5+
pull_request_target:
6+
types: [opened, reopened, synchronize]
67

78
concurrency:
89
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -14,24 +15,22 @@ env:
1415

1516
jobs:
1617
commitlint:
17-
if: github.event_name == 'pull_request'
18-
env:
19-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
if: github.event_name == 'pull_request_target'
2019
runs-on: ubuntu-latest
2120
steps:
2221
- uses: actions/checkout@v4
2322
with:
2423
fetch-depth: 0
2524
- name: Run commitlint
2625
run: |
27-
commit=$(gh api \
28-
/repos/${{ github.repository }}/pulls/${{github.event.number}}/commits \
29-
| jq -r '.[0].commit.message' \
30-
| head -n 1)
26+
base_sha="${{ github.event.pull_request.base.sha }}"
27+
head_sha="${{ github.event.pull_request.head.sha }}"
28+
first_commit_sha=$(git rev-list --no-merges --reverse $base_sha..$head_sha | head -n 1)
29+
commit_message=$(git log -1 --pretty=%B $first_commit_sha)
3130
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
3231
echo '{}' > package.json
3332
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
34-
echo $commit | ./node_modules/.bin/commitlint -g .commitlintrc
33+
echo "$commit_message" | ./node_modules/.bin/commitlint -g .commitlintrc
3534
3635
architecture:
3736
name: Check components interdependencies

0 commit comments

Comments
 (0)