Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDEnYO committed Jul 25, 2024
1 parent 55942c8 commit ca90801
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions .github/workflows/diamondEmergencyPause.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca90801

Please sign in to comment.