Skip to content

Commit

Permalink
Fix workflow permission check logic (#4084)
Browse files Browse the repository at this point in the history
### Description
This improves the permission checking logic for running github actions.
We also have it setup to only run actions by organization members, but
this acts as an additional check.

---------

Co-authored-by: Andy Boedo <[email protected]>
  • Loading branch information
tonidero and aboedo authored Jul 19, 2024
1 parent f6cb37f commit d9f783b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/trigger_all_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ jobs:
runs-on: ubuntu-latest
if: |
${{ github.event.issue.pull_request }} &&
github.event.comment.body == '@RCGitBot please test'
github.event.comment.body == '@RCGitBot please test' &&
github.repository == 'RevenueCat/purchases-ios'
steps:
- name: Check membership in RevenueCat Org
env:
READ_ORG_GITHUB_TOKEN: ${{ secrets.READ_ORG_GITHUB_TOKEN }}
id: verify
# ensure that only RevenueCat members can trigger this
run: |
RESPONSE=$(curl https://api.github.com/orgs/RevenueCat/members/${{ github.event.comment.user.login }})
if [[ "$RESPONSE" == *"Not Found"* ]]; then
RESPONSE=$(curl -s -o /dev/null --head -w "%{http_code}" -H "Authorization: Bearer $READ_ORG_GITHUB_TOKEN" https://api.github.com/orgs/RevenueCat/members/${{ github.event.comment.user.login }})
if [[ "$RESPONSE" != "204" ]]; then
echo "User is not a member of the organization"
exit 1
fi
Expand Down

0 comments on commit d9f783b

Please sign in to comment.