Skip to content

Commit 92dd70b

Browse files
authored
ci: rate limiting for commitlint (#7253)
1 parent 3ac8267 commit 92dd70b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: CI
33
on:
44
push:
55
pull_request:
6+
pull_request_target:
7+
types: [opened, reopened, synchronize]
68

79
concurrency:
810
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -14,24 +16,22 @@ env:
1416

1517
jobs:
1618
commitlint:
17-
if: github.event_name == 'pull_request'
18-
env:
19-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
if: github.event_name == 'pull_request_target'
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
2323
with:
2424
fetch-depth: 0
2525
- name: Run commitlint
2626
run: |
27-
commit=$(gh api \
28-
/repos/${{ github.repository }}/pulls/${{github.event.number}}/commits \
29-
| jq -r '.[0].commit.message' \
30-
| head -n 1)
27+
base_sha="${{ github.event.pull_request.base.sha }}"
28+
head_sha="${{ github.event.pull_request.head.sha }}"
29+
first_commit_sha=$(git rev-list --no-merges --reverse $base_sha..$head_sha | head -n 1)
30+
commit_message=$(git log -1 --pretty=%B $first_commit_sha)
3131
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
3232
echo '{}' > package.json
3333
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
34-
echo $commit | ./node_modules/.bin/commitlint -g .commitlintrc
34+
echo "$commit_message" | ./node_modules/.bin/commitlint -g .commitlintrc
3535
3636
architecture:
3737
name: Check components interdependencies
@@ -1088,15 +1088,16 @@ jobs:
10881088
ini-values: memory_limit=-1
10891089
# Not in pecl
10901090
- name: Setup mongodb
1091+
shell: bash
10911092
run: |
10921093
curl -sLO https://github.com/mongodb/mongo-php-driver/releases/download/1.17.2/php_mongodb-1.17.2-8.3-nts-x64.zip
10931094
unzip -q php_mongodb-1.17.2-8.3-nts-x64.zip php_mongodb.dll
1094-
mv php_mongodb.dll C:\tools\php\ext
1095-
echo "extension=php_mongodb.dll" >> C:\tools\php\php.ini
1095+
mv php_mongodb.dll C:/tools/php/ext
1096+
echo "extension=php_mongodb.dll" >> C:/tools/php/php.ini
10961097
- name: Get composer cache directory
10971098
id: composercache
1098-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
10991099
shell: bash
1100+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
11001101
- name: Cache dependencies
11011102
uses: actions/cache@v4
11021103
with:
@@ -1105,18 +1106,21 @@ jobs:
11051106
restore-keys: ${{ runner.os }}-composer-
11061107
- name: Keep windows path
11071108
id: get-cwd
1109+
shell: bash
11081110
run: |
11091111
cwd=$(php -r 'echo(str_replace("\\", "\\\\", $_SERVER["argv"][1]));' '${{ github.workspace }}')
11101112
echo cwd=$cwd >> $GITHUB_OUTPUT
1111-
shell: bash
11121113
- name: Update project dependencies
1114+
shell: bash
11131115
run: |
11141116
composer global require soyuka/pmu
11151117
composer global config allow-plugins.soyuka/pmu true --no-interaction
11161118
composer global link . --working-directory='${{ steps.get-cwd.outputs.cwd }}'
11171119
- name: Clear test app cache
1120+
shell: bash
11181121
run: tests/Fixtures/app/console cache:clear --ansi
11191122
- name: Run Behat tests
1123+
shell: bash
11201124
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction
11211125

11221126
phpunit-symfony-lowest:

0 commit comments

Comments
 (0)