Skip to content

Commit 1da29fc

Browse files
authored
Harden sync PR gate (#11704)
Co-authored-by: yevh <yevh@users.noreply.github.com>
1 parent cb95219 commit 1da29fc

1 file changed

Lines changed: 7 additions & 31 deletions

File tree

.github/workflows/sync-pr-gate.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: Sync PR Gate (Hoodi)
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
branches: [master]
6-
pull_request_review:
7-
types: [submitted]
86

97
concurrency:
108
group: sync-pr-${{ github.event.pull_request.number }}
@@ -14,37 +12,13 @@ env:
1412
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: "1"
1513
TERM: xterm
1614

17-
jobs:
18-
check-approval:
19-
name: "Check PR approval"
20-
if: >-
21-
github.event_name == 'pull_request_target' ||
22-
github.event.review.state == 'approved'
23-
runs-on: ubuntu-latest
24-
outputs:
25-
run: ${{ steps.check.outputs.run }}
26-
steps:
27-
- name: Check if sync should run
28-
id: check
29-
env:
30-
GH_TOKEN: ${{ github.token }}
31-
IS_FORK: ${{ github.event.pull_request.head.repo.fork }}
32-
PR_NUMBER: ${{ github.event.pull_request.number }}
33-
run: |
34-
if [ "$IS_FORK" != "true" ]; then
35-
echo "run=true" >> "$GITHUB_OUTPUT"
36-
exit 0
37-
fi
38-
39-
# Fork PR: only run if at least one approval exists
40-
approved=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}/reviews" \
41-
--jq '[.[] | select(.state == "APPROVED")] | length > 0')
42-
echo "run=$approved" >> "$GITHUB_OUTPUT"
15+
permissions:
16+
contents: read
4317

18+
jobs:
4419
sync-hoodi:
4520
name: "Sync hoodi (${{ matrix.mode }})"
46-
needs: check-approval
47-
if: needs.check-approval.outputs.run == 'true'
21+
if: github.event.pull_request.head.repo.fork == false
4822
runs-on: ubuntu-arm64-8-core
4923
timeout-minutes: 180
5024
strategy:
@@ -70,6 +44,7 @@ jobs:
7044
uses: actions/checkout@v6
7145
with:
7246
ref: ${{ github.event.pull_request.head.sha }}
47+
persist-credentials: false
7348

7449
- name: Checkout tests repository
7550
uses: actions/checkout@v6
@@ -78,6 +53,7 @@ jobs:
7853
path: tests
7954
token: ${{ steps.gh-app.outputs.token }}
8055
clean: true
56+
persist-credentials: false
8157

8258
- name: Cache apt packages
8359
uses: awalsh128/cache-apt-pkgs-action@v1

0 commit comments

Comments
 (0)