-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): verify triggering actor on pull request from fork
If a contributor that open a Pull Request from a fork is not part of the repository collaborators, then the workflow using check_triggering_actor subworkflowwill exit with a failure. It could be re-run later by a collaborator who has a write access. This allows reviewers to read the code proposition before running the CI, ensuring no secrets are leaked outside the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Check if triggering actor is a collaborator and has write access | ||
name: Check Triggering Actor | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
GITHUB_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
check-actor-permission: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get User Permission | ||
id: check-access | ||
uses: actions-cool/check-user-permission@956b2e73cdfe3bcb819bb7225e490cb3b18fd76e # v2.2.1 | ||
with: | ||
require: write | ||
username: ${{ github.triggering_actor }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check User Permission | ||
if: steps.check-access.outputs.require-result == 'false' | ||
run: | | ||
echo "${{ github.triggering_actor }} does not have permissions on this repo." | ||
echo "Current permission level is ${{ steps.check-access.outputs.user-permission }}" | ||
echo "Job originally triggered by ${{ github.actor }}" | ||
exit 1 |