1717 if : github.event.action != 'labeled' || github.event.label.name == 'ok-to-test'
1818 permissions :
1919 contents : read
20- pull-requests : read
21- issues : read
2220 outputs :
2321 authorized : ${{ steps.check.outputs.authorized }}
2422 steps :
2725 env :
2826 GH_TOKEN : ${{ github.token }}
2927 EVENT_NAME : ${{ github.event_name }}
28+ EVENT_ACTION : ${{ github.event.action }}
3029 USER : ${{ github.event.pull_request.user.login || github.actor }}
31- PR_NUMBER : ${{ github.event.pull_request.number }}
30+ ACTOR : ${{ github.actor }}
3231 REPOSITORY : ${{ github.repository }}
3332 run : |
3433 set -euo pipefail
@@ -50,16 +49,12 @@ jobs:
5049 allow "$USER is an owner or developer."
5150 fi
5251
53- [ -n "${PR_NUMBER:-}" ] || deny "$USER is not an owner or developer."
52+ # ok-to-test only counts on the labeled event, so a later push cannot
53+ # reuse an old owner approval against a new PR head.
54+ [ "$EVENT_ACTION" = "labeled" ] || deny "$USER is not an owner or developer."
5455
55- gh api "repos/${REPOSITORY}/issues/${PR_NUMBER}/labels" --jq '.[].name' \
56- | grep -Fxq ok-to-test || deny "No ok-to-test label."
57-
58- LABELER=$(gh api --paginate "repos/${REPOSITORY}/issues/${PR_NUMBER}/events?per_page=100" \
59- --jq '.[] | select(.event=="labeled" and .label.name=="ok-to-test") | .actor.login' \
60- | tail -n1)
61- LABELER_PERM=$(perm "$LABELER")
62- echo "ok-to-test labeler=$LABELER permission=$LABELER_PERM"
63- [ "$LABELER_PERM" = "admin" ] && allow "Owner $LABELER added ok-to-test."
56+ LABELER_PERM=$(perm "$ACTOR")
57+ echo "ok-to-test labeler=$ACTOR permission=$LABELER_PERM"
58+ [ "$LABELER_PERM" = "admin" ] && allow "Owner $ACTOR added ok-to-test."
6459
6560 deny "ok-to-test was not added by an owner."
0 commit comments