Skip to content

Commit 6377404

Browse files
author
Radovan Fuchs
committed
bind to latest commit based on coderabbit suggestion
1 parent 3998a28 commit 6377404

5 files changed

Lines changed: 12 additions & 25 deletions

File tree

.github/workflows/e2e_authorize.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ jobs:
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:
@@ -27,8 +25,9 @@ jobs:
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."

.github/workflows/e2e_tests.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
uses: ./.github/workflows/e2e_authorize.yaml
1313
permissions:
1414
contents: read
15-
pull-requests: read
16-
issues: read
1715

1816
e2e_tests:
1917
needs: authorize
@@ -66,9 +64,9 @@ jobs:
6664
# On push → falls back to the current repository.
6765
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
6866

69-
# On PR_TARGET → the PR head *commit* (reproducible).
67+
# On PR_TARGET → the PR head commit at event time (not the moving branch).
7068
# On push → the pushed commit that triggered the workflow.
71-
ref: ${{ github.event.pull_request.head.ref || github.sha }}
69+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
7270

7371
# Tests need access to secrets.
7472
# This should be refactored if possible to mitigate the risk.

.github/workflows/e2e_tests_lightspeed_evaluation.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
uses: ./.github/workflows/e2e_authorize.yaml
1212
permissions:
1313
contents: read
14-
pull-requests: read
15-
issues: read
1614

1715
e2e_tests:
1816
needs: authorize
@@ -36,9 +34,9 @@ jobs:
3634
# On push → falls back to the current repository.
3735
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
3836

39-
# On PR_TARGET → the PR head *commit* (reproducible).
37+
# On PR_TARGET → the PR head commit at event time (not the moving branch).
4038
# On push → the pushed commit that triggered the workflow.
41-
ref: ${{ github.event.pull_request.head.ref || github.sha }}
39+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
4240

4341
# Don’t keep credentials when running untrusted PR code under PR_TARGET.
4442
persist-credentials: ${{ github.event_name != 'pull_request_target' }}

.github/workflows/e2e_tests_providers.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
uses: ./.github/workflows/e2e_authorize.yaml
1313
permissions:
1414
contents: read
15-
pull-requests: read
16-
issues: read
1715

1816
e2e_tests:
1917
needs: authorize

.github/workflows/e2e_tests_rhaiis.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ jobs:
1313
uses: ./.github/workflows/e2e_authorize.yaml
1414
permissions:
1515
contents: read
16-
pull-requests: read
17-
issues: read
1816

1917
e2e_tests:
2018
needs: authorize

0 commit comments

Comments
 (0)