Skip to content

Commit 9fa6a85

Browse files
authored
Add authorization test for random-test (#2789)
1 parent b052f5b commit 9fa6a85

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

.github/workflows/random-test.yaml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,32 @@ permissions:
2727
contents: read
2828

2929
jobs:
30-
test:
30+
check-permission:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
authorized: ${{ steps.makeDecision.outputs.continue }}
34+
steps:
35+
- id: checkUser
36+
uses: tspascoal/get-user-teams-membership@v3
37+
with:
38+
username: ${{ github.actor }}
39+
team: 'FlagGems'
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- id: makeDecision
43+
env:
44+
IS_MEMBER: ${{ steps.checkUser.outputs.isTeamMember }}
45+
run: |
46+
if [[ "${IS_MEMBER}" == "false" ]]; then
47+
echo "Unauthorized user: ${{ github.actor }}"
48+
echo "continue=false" >> $GITHUB_OUTPUT
49+
else
50+
echo "continue=true" >> $GITHUB_OUTPUT
51+
fi
52+
53+
test-operator:
54+
needs: check-permission
55+
if: needs.check-permission.outputs.authorized == 'true'
3156
runs-on: ${{ inputs.runner }}
3257
steps:
3358
# - name: Set global proxy
@@ -47,11 +72,6 @@ jobs:
4772
# ;;
4873
# esac
4974

50-
- name: Dump context
51-
env:
52-
GITHUB_CONTEXT: ${{ toJSON(github) }}
53-
run: echo "$GITHUB_CONTEXT"
54-
5575
- uses: actions/checkout@v6
5676
# with:
5777
# ssh-key: ${{ secrets.RUNNER_SSH_KEY }}

0 commit comments

Comments
 (0)