You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if [ "$org" == "$GITHUB_REPOSITORY_OWNER" ]; then org_found=1; fi
60
+
done
61
+
for event in $ALLOWED_EVENTS; do
62
+
if [ "$event" == "$GITHUB_EVENT_NAME" ]; then event_found=1; fi
63
+
done
64
+
for ref in $ALLOWED_REFS; do
65
+
if [ ${{ inputs.deployment_env }} == 'prod' ]; then
66
+
if [ "$ref" == "$GITHUB_REF" ]; then ref_found=1; fi
67
+
else
68
+
ref_found=1
69
+
fi
70
+
done
71
+
for user in $ALLOWED_USERS; do
72
+
if [ ${{ inputs.deployment_env }} == 'prod' ]; then
73
+
if [ "$user" == "$GITHUB_ACTOR" ]; then user_found=1; fi
74
+
else
75
+
user_found=1
76
+
fi
77
+
done
78
+
if [ $org_found$event_found$ref_found$user_found -ne 1111 ]; then
79
+
echo "Repository owner, event, ref or actor are not explicitely allowed to use this workflow: $GITHUB_REPOSITORY_OWNER, $GITHUB_EVENT_NAME, $GITHUB_REF, $GITHUB_ACTOR"
80
+
exit 1
81
+
fi
82
+
exit 0
83
+
84
+
build-staging:
85
+
name: build-staging
86
+
runs-on: ubuntu-latest
87
+
needs: check-if-allowed
88
+
if: ${{ inputs.deployment_env == 'staging' }}
89
+
90
+
steps:
44
91
- name: Install dependencies
45
92
run: |
46
93
sudo apt-get update
@@ -49,56 +96,14 @@ jobs:
49
96
- name: Checkout
50
97
uses: actions/checkout@v4
51
98
52
-
- name: Check prod access
53
-
if: ${{ inputs.deployment_env == 'prod' }}
54
-
run: |
55
-
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
56
-
echo "Error: Production deployments are only allowed from the main branch."
57
-
exit 1
58
-
fi
59
-
60
-
if [ "$GITHUB_REPOSITORY_OWNER" != "nginx" ] && [ "$GITHUB_REPOSITORY_OWNER" != "nginxinc" ]; then
61
-
echo "Error: This workflow is only allowed in repositories owned by 'nginx' or 'nginxinc'."
62
-
exit 1
63
-
fi
64
-
65
-
ALLOWED="${{ secrets.ALLOWED_USERS }}"
66
-
for user in $ALLOWED; do
67
-
if [ "$GITHUB_ACTOR" == "$user" ]; then
68
-
echo "User $GITHUB_ACTOR is allowed to deploy to prod"
69
-
exit 0
70
-
fi
71
-
done
72
-
73
-
echo "User $GITHUB_ACTOR is NOT allowed to deploy to prod"
0 commit comments