Skip to content

Commit

Permalink
ci: ✨ check PR author and not actor
Browse files Browse the repository at this point in the history
Allowing external contributors to run actions would be quite bad.
We just need to expand the rights of some of the team members
  • Loading branch information
melMass authored Aug 9, 2023
1 parent 5fea800 commit 9248161
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ jobs:
outputs:
level: ${{ steps.access_check.outputs.has-write }}
steps:
- name: 🗝️ Check if initiator has write access
- name: 🗝️ Check if author has write access
id: access_check
run: |
PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission" | jq -r .permission)
echo "Permissions of ${{ github.actor }}: ${PERMISSION}"
PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission" | jq -r .permission)
echo "Workflow ran by ${{ github.actor }}"
echo "Permissions of ${{ github.event.pull_request.user.login }}: ${PERMISSION}"
echo "has-write=${PERMISSION}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 9248161

Please sign in to comment.