@@ -6,17 +6,20 @@ concurrency:
66 cancel-in-progress : true
77
88on :
9- pull_request :
9+ pull_request_target :
1010 types : [labeled, synchronize]
1111
1212jobs :
1313 get-jobs :
1414 runs-on : ubuntu-latest
15+ environment : fork-pr-validation
1516 outputs :
1617 search-space-config : ${{ steps.get-jobs.outputs.search-space-config }}
1718 steps :
1819 - name : Checkout code
1920 uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
21+ with :
22+ ref : ${{ github.event.pull_request.head.sha }}
2023
2124 - id : get-jobs
2225 shell : python
@@ -79,12 +82,15 @@ jobs:
7982
8083 validate :
8184 needs : get-jobs
82- if : ${{ needs.get-jobs.outputs.search-space-config != '[]' }}
85+ if : ${{ always() && needs.get-jobs.result == 'success' && needs.get-jobs.outputs.search-space-config != '[]' }}
8386 uses : ./.github/workflows/benchmark-tmpl.yml
8487 strategy :
8588 fail-fast : false
8689 matrix :
87- config : ${{ fromJson(needs.get-jobs.outputs.search-space-config) }}
90+ # The '|| '[]'' fallback is required because GitHub evaluates the matrix expression
91+ # before the 'if' condition. Without it, fromJson() throws a parse error when the
92+ # output is empty/undefined (e.g., when get-jobs is pending approval or was skipped).
93+ config : ${{ fromJson(needs.get-jobs.outputs.search-space-config || '[]') }}
8894 secrets : inherit
8995 name : validate ${{ matrix.config.runner }}
9096 with :
@@ -106,14 +112,14 @@ jobs:
106112 disagg : ${{ matrix.config.disagg }}
107113
108114 collect-results :
109- needs : validate
110- if : ${{ always() }}
115+ needs : [get-jobs, validate]
116+ if : ${{ always() && needs.get-jobs.result == 'success' }}
111117 uses : ./.github/workflows/collect-results.yml
112118 secrets : inherit
113119
114120 calc-success-rate :
115- needs : collect-results
116- if : ${{ always() }}
121+ needs : [get-jobs, collect-results]
122+ if : ${{ always() && needs.get-jobs.result == 'success' }}
117123 runs-on : ubuntu-latest
118124
119125 env :
0 commit comments