Skip to content

Commit 262d567

Browse files
committed
ci(package): allow workflow to access the environment secrets
When Dependabot pushes the branch, the workflow would run from the tip of the pushed branch if triggered via the `push` event, hence it would be unsafe to give it access to the environment secrets. Instead, let's trigger on `pull_request_target`, which will run the workflow as per `main`, where it is safe to access the environment secrets. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent c929a1e commit 262d567

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

.github/workflows/npm-run-package.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
name: 'npm run package'
22
# Main use case: repackage when Dependabot updates a dependency
33
on:
4-
push:
5-
branches:
6-
- 'dependabot/**'
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
paths:
10+
- package.json
11+
- package-lock.json
712
workflow_dispatch:
813
inputs:
914
branch:
@@ -14,11 +19,13 @@ on:
1419
jobs:
1520
npm-run-package-and-push: # make sure build/ci work properly
1621
runs-on: ubuntu-latest
22+
if: ${{ github.event_name }} == 'workflow_dispatch' || ${{ github.actor }} == 'dependabot[bot]' || ${{ github.actor }} == 'dscho'
1723
environment: git-for-windows-ci-push
1824
steps:
1925
- uses: actions/checkout@v2
2026
with:
21-
ref: ${{ inputs.branch }}
27+
repository: ${{ github.event.pull_request.head.repo.full_name }}
28+
ref: ${{ inputs.branch }}${{ github.event.pull_request.head.ref }}
2229
token: ${{ secrets.GIT_FOR_WINDOWS_CI_PUSH }}
2330
- run: npm ci
2431
- run: npm run build

0 commit comments

Comments
 (0)