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 3, 2024
1 parent 4d78663 commit 1fa1d25
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ concurrency:
cancel-in-progress: true

jobs:
# We must first check whether it is a external contribution, before processing to checkout the code and running jobs with access to secrets
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
# This is dangerous without the first access check
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

formatting-linting:
name: Formatting, linting & changeset checks
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
Expand Down Expand Up @@ -157,23 +182,6 @@ 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:
Expand Down

0 comments on commit 1fa1d25

Please sign in to comment.