@@ -14,43 +14,31 @@ jobs:
1414 contains(github.event.comment.body, '/deploy-preview'))
1515 outputs :
1616 allowed : ${{ steps.check-team.outputs.allowed }}
17- pr-number : ${{ steps.pr-info .outputs.number }}
17+ pr-number : ${{ steps.check-team .outputs.number }}
1818 steps :
19- - name : Get PR info
20- id : pr-info
19+ - name : Get PR info and check permissions
20+ id : check-team
2121 env :
2222 EVENT_NAME : ${{ github.event_name }}
2323 PR_NUMBER : ${{ github.event.pull_request.number }}
24- PR_ACTOR : ${{ github.event.pull_request.user.login }}
24+ PR_ASSOCIATION : ${{ github.event.pull_request.author_association }}
2525 COMMENT_NUMBER : ${{ github.event.issue.number }}
26- COMMENT_ACTOR : ${{ github.event.comment.user.login }}
26+ COMMENT_ASSOCIATION : ${{ github.event.comment.author_association }}
2727 run : |
2828 if [[ "$EVENT_NAME" == "pull_request_target" ]]; then
2929 echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
30- echo "actor=$PR_ACTOR" >> $GITHUB_OUTPUT
30+ ASSOCIATION="$PR_ASSOCIATION"
3131 else
3232 echo "number=$COMMENT_NUMBER" >> $GITHUB_OUTPUT
33- echo "actor=$COMMENT_ACTOR" >> $GITHUB_OUTPUT
33+ ASSOCIATION="$COMMENT_ASSOCIATION"
3434 fi
3535
36- - name : Check team membership
37- id : check-team
38- env :
39- GH_READ_ORG_TOKEN : ${{ secrets.GH_READ_ORG_TOKEN }}
40- ACTOR : ${{ steps.pr-info.outputs.actor }}
41- ORG : patternfly
42- TEAM : frequent-flyers
43- run : |
44- RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
45- -H "Authorization: token $GH_READ_ORG_TOKEN" \
46- -H "Accept: application/vnd.github.v3+json" \
47- "https://api.github.com/orgs/$ORG/teams/$TEAM/members/$ACTOR")
48- if [[ "$RESPONSE" == "204" ]]; then
36+ if [[ "$ASSOCIATION" == "OWNER" || "$ASSOCIATION" == "MEMBER" || "$ASSOCIATION" == "COLLABORATOR" ]]; then
4937 echo "allowed=true" >> $GITHUB_OUTPUT
50- echo "$ACTOR is a member of $TEAM "
38+ echo "User is a repo $ASSOCIATION — allowed "
5139 else
5240 echo "allowed=false" >> $GITHUB_OUTPUT
53- echo "$ACTOR is not a member of $TEAM "
41+ echo "User association is $ASSOCIATION — not allowed "
5442 fi
5543
5644 deploy-preview :
0 commit comments