-
Notifications
You must be signed in to change notification settings - Fork 100
43 lines (38 loc) · 1.23 KB
/
authorized_users.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Authorized Users
on:
workflow_dispatch:
pull_request:
push:
branches:
- '*'
jobs:
check-authorization:
runs-on: ubuntu-latest
outputs:
approved: ${{ steps.gatekeeper.outputs.approved }}
steps:
- name: Check if user is approved
id: gatekeeper
run: |
# Define the allowlist of users and teams
# echo out who the actor is
echo "The actor is: ${GITHUB_ACTOR}"
APPROVED_USERS=("nikellepetrillo")
#APPROVED_TEAMS=("dsp-devops")
# Check if the user is in the allowlist
if [[ " ${APPROVED_USERS[@]} " =~ " ${GITHUB_ACTOR} " ]]; then
echo "User ${GITHUB_ACTOR} is approved."
echo "approved=true" >> $GITHUB_ENV
else
echo "User ${GITHUB_ACTOR} is not approved."
echo "approved=false" >> $GITHUB_ENV
fi
- name: Fail if not approved
if: ${{ env.approved == 'false' }}
run: |
echo "This workflow is restricted. Approval required."
exit 1
- name: Continue workflow if approved
if: ${{ env.approved == 'true' }}
run: |
echo "Proceeding with the workflow for approved user: ${GITHUB_ACTOR}"