Skip to content

Commit 0186534

Browse files
committed
Update ci.yml.
1 parent bae5369 commit 0186534

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: hCaptcha CI
22
on: [ push, pull_request ]
3+
4+
# 1. SECURITY: Default to read-only permissions for the workflow
5+
permissions:
6+
actions: read
7+
contents: read
8+
39
concurrency:
410
group: ${{ github.ref }}
511
cancel-in-progress: true
@@ -35,10 +41,8 @@ jobs:
3541
with:
3642
path: ${{ env.wp-plugin-directory }}
3743

38-
- name: Update changelog
39-
if: ${{ matrix.php-version == '8.4' }}
40-
working-directory: ${{ env.wp-plugin-directory }}
41-
run: .github/scripts/update-changelog.sh
44+
# MOVED: The "Update changelog" step has been moved to the specific job below
45+
# to prevent giving 'contents: write' permissions to this testing job.
4246

4347
- name: Setup PHP
4448
uses: hCaptcha/setup-php@42a9487ddd45db247decea2acf7de871a8178226
@@ -115,3 +119,30 @@ jobs:
115119
if: ${{ matrix.php-version == '8.4' }}
116120
working-directory: ${{ env.wp-plugin-directory }}
117121
run: yarn jest
122+
123+
update_changelog:
124+
name: Update Changelog
125+
runs-on: ubuntu-latest
126+
127+
# 2. SECURITY: Only run on PUSH, never on Pull Requests
128+
if: github.event_name == 'push'
129+
needs: cs_and_tests
130+
131+
# 3. SECURITY: Grant write permission ONLY to this job
132+
permissions:
133+
contents: write
134+
135+
env:
136+
wp-plugin-directory: wordpress/wp-content/plugins/hcaptcha-wordpress-plugin
137+
138+
steps:
139+
- name: Checkout code
140+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
141+
with:
142+
path: ${{ env.wp-plugin-directory }}
143+
# Check out the branch ref to ensure we can push back to it
144+
ref: ${{ github.ref }}
145+
146+
- name: Update changelog
147+
working-directory: ${{ env.wp-plugin-directory }}
148+
run: .github/scripts/update-changelog.sh

0 commit comments

Comments
 (0)