Skip to content

Commit d87fc2b

Browse files
committed
Restrict action to members of the org
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 100433f commit d87fc2b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.github/workflows/pr-deploy.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ permissions:
3434
pull-requests: write # needed for commenting on PRs
3535

3636
jobs:
37+
check_membership:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Check if actor is a member
41+
run: |
42+
set -euo pipefail
43+
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/orgs/coder/members/${{ github.actor }}")
44+
if [[ "$response" == "404" ]]; then
45+
echo "Error: Only members of the coder organization can trigger this workflow."
46+
exit 1
47+
fi
3748
check_pr:
3849
runs-on: ubuntu-latest
3950
outputs:

0 commit comments

Comments
 (0)