From ca90801b2301cc7f1717a2ce072c676f85060590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Bl=C3=A4cker?= Date: Thu, 25 Jul 2024 19:58:30 +0700 Subject: [PATCH] test --- .github/workflows/diamondEmergencyPause.yml | 32 +++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/diamondEmergencyPause.yml b/.github/workflows/diamondEmergencyPause.yml index 9489f7ac3..e6293230c 100644 --- a/.github/workflows/diamondEmergencyPause.yml +++ b/.github/workflows/diamondEmergencyPause.yml @@ -12,34 +12,30 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Get team members - id: get-team-members - uses: garnertb/get-team-members@v1 - with: - token: ${{ GITHUB.TOKEN }} - org: lifinance - team_slug: diamondpauser + - name: Install GitHub CLI + run: sudo apt-get install gh -y - - name: Check if action was triggered by a member of Github "DiamondPauser" group + - name: Get team members and check authorization id: authenticate + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + TEAM_NAME="diamondpauser" + ORG_NAME="lifinance" USER=${{ github.actor }} - TEAM_MEMBERS=${{ steps.get-team-members.outputs.members }} - echo "TEAM_MEMBERS: $TEAM_MEMBERS" + # Get the team members + TEAM_MEMBERS=$(gh api --paginate -X GET /orgs/$ORG_NAME/teams/$TEAM_NAME/members | jq -r '.[].login') - if [[ -z "$GITHUB.TOKEN" ]]; then - echo "GITHUB.TOKEN is empty" - fi + echo "TEAM_MEMBERS=$TEAM_MEMBERS" >> $GITHUB_ENV - if [[ -z "$github.token" ]]; then - echo "github.token is empty" - fi + echo "TEAM_MEMBERS: $TEAM_MEMBERS" + # Check if the user is in the team members if echo "$TEAM_MEMBERS" | grep -q "$USER"; then - echo "User $USER is a member of team diamondpauser and authorized to execute this action." + echo "User $USER is a member of team $TEAM_NAME and authorized to execute this action." else - echo "You ($USER) are not authorized to execute this action. Please ask any of these people to execute the action: https://github.com/orgs/lifinance/teams/diamondpauser/members" + echo "You ($USER) are not authorized to execute this action. Please ask any of these people to execute the action: https://github.com/orgs/$ORG_NAME/teams/$TEAM_NAME/members" exit 1 fi shell: bash