From aa2c4c6bcfd23ff75758bac8db42aa7331442616 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 7 Sep 2024 10:19:56 -0700 Subject: [PATCH 1/2] Update bypass-review.yaml Check the user's role using memberships API (works for both public and private members) --- .github/workflows/bypass-review.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bypass-review.yaml b/.github/workflows/bypass-review.yaml index 1ddeddcab..dd5b1606b 100644 --- a/.github/workflows/bypass-review.yaml +++ b/.github/workflows/bypass-review.yaml @@ -25,8 +25,15 @@ jobs: env: GH_TOKEN: ${{ secrets.ADMIN_PAT }} run: | + # Get the author of the PR AUTHOR=$(gh pr view ${{ github.event.pull_request.number }} --json author --jq '.author.login') - ADMIN_CHECK=$(gh api orgs/scidsg/members/$AUTHOR --jq '.role') + + # Check the user's role using memberships API (works for both public and private members) + ADMIN_CHECK=$(gh api orgs/scidsg/memberships/$AUTHOR --jq '.role') + + # Output the result for debugging purposes + echo "Admin check response: $ADMIN_CHECK" + if [ "$ADMIN_CHECK" != "admin" ]; then echo "User is not an admin or is not a public member of the organization. Exiting." exit 1 From 2d1e1522208c34a5a0a39bc1bd5f03f52df1d547 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 7 Sep 2024 11:06:40 -0700 Subject: [PATCH 2/2] Update bypass-review.yaml --- .github/workflows/bypass-review.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bypass-review.yaml b/.github/workflows/bypass-review.yaml index dd5b1606b..f323703b2 100644 --- a/.github/workflows/bypass-review.yaml +++ b/.github/workflows/bypass-review.yaml @@ -31,11 +31,9 @@ jobs: # Check the user's role using memberships API (works for both public and private members) ADMIN_CHECK=$(gh api orgs/scidsg/memberships/$AUTHOR --jq '.role') - # Output the result for debugging purposes - echo "Admin check response: $ADMIN_CHECK" - + # If the user isn't an admin, exit with a detailed error message if [ "$ADMIN_CHECK" != "admin" ]; then - echo "User is not an admin or is not a public member of the organization. Exiting." + echo "User is not an admin. Their role is: $ADMIN_CHECK. Exiting." exit 1 fi