Skip to content

Commit

Permalink
Introduce permissions check job
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Dec 4, 2024
1 parent 4d78663 commit 8dd9ea4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .changeset/unlucky-buses-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
39 changes: 20 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ concurrency:
cancel-in-progress: true

jobs:
# Check triggering actor permissions to prevent PRs from forks accessing secrets by default, preventing them from exfiltrating secrets for malicious purposes
check-permissions:
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
steps:
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1
formatting-linting:
name: Formatting, linting & changeset checks
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
Expand Down Expand Up @@ -157,30 +177,11 @@ jobs:
next-version: '15'

steps:
# Skip integration tests from fork PRs to prevent secret exfiltration
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
# We must first verify the user permissions before checking out PR code
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup
id: config
Expand Down

0 comments on commit 8dd9ea4

Please sign in to comment.