@@ -46,21 +46,42 @@ jobs:
4646 else
4747 # Get PR number from workflow_run
4848 PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}"
49+ if [ -z "$PR_NUMBER" ]; then
50+ # Cross-repo PRs don't populate pull_requests[]. Search by head SHA.
51+ HEAD_SHA="${{ github.event.workflow_run.head_sha }}"
52+ PR_NUMBER=$(gh api "repos/${{ github.repository }}/pulls?state=open&sort=updated&direction=desc&per_page=30" \
53+ --jq ".[] | select(.head.sha == \"$HEAD_SHA\") | .number" | head -1)
54+ fi
55+ if [ -z "$PR_NUMBER" ]; then
56+ # workflow_run may report the merge/base SHA for forks. Fall back to branch name.
57+ HEAD_BRANCH="${{ github.event.workflow_run.head_branch }}"
58+ if [ -n "$HEAD_BRANCH" ] && [ "$HEAD_BRANCH" != "master" ]; then
59+ PR_NUMBER=$(gh api "repos/${{ github.repository }}/pulls?state=open&sort=updated&direction=desc&per_page=30" \
60+ --jq ".[] | select(.head.ref == \"$HEAD_BRANCH\") | .number" | head -1)
61+ fi
62+ fi
63+
4964 if [ -n "$PR_NUMBER" ]; then
5065 echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
5166
5267 # Fetch actual PR author from API (workflow_run.actor is the re-runner, not PR author)
5368 PR_AUTHOR=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER --jq '.user.login')
5469 echo "author=$PR_AUTHOR" >> $GITHUB_OUTPUT
5570
56- # Check if PR is approved
57- APPROVED=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews \
58- --jq '[.[] | select(.state == "APPROVED")] | length')
59- if [ "$APPROVED" -gt 0 ]; then
60- echo "approved=true" >> $GITHUB_OUTPUT
61- else
62- echo "approved=false" >> $GITHUB_OUTPUT
63- fi
71+ # Check if PR is approved by a maintainer/admin (ignore AI bot approvals)
72+ APPROVERS=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \
73+ --jq '[.[] | select(.state == "APPROVED") | .user.login] | unique | .[]')
74+ APPROVED="false"
75+ for approver in $APPROVERS; do
76+ PERM=$(gh api "repos/${{ github.repository }}/collaborators/$approver/permission" \
77+ --jq '.permission' 2>/dev/null || echo "none")
78+ if [ "$PERM" = "admin" ] || [ "$PERM" = "maintain" ] || [ "$PERM" = "write" ]; then
79+ echo " Approved by $approver (permission: $PERM)"
80+ APPROVED="true"
81+ break
82+ fi
83+ done
84+ echo "approved=$APPROVED" >> $GITHUB_OUTPUT
6485 else
6586 echo "pr_number=" >> $GITHUB_OUTPUT
6687 echo "approved=false" >> $GITHUB_OUTPUT
7697 (
7798 github.event_name == 'workflow_dispatch' ||
7899 needs.file-changes.outputs.pr_approved == 'true' ||
79- needs.file-changes.outputs.pr_author == 'sbryngelson' ||
80- needs.file-changes.outputs.pr_author == 'wilfonba'
100+ needs.file-changes.outputs.pr_author == 'sbryngelson'
81101 )
82102 needs : [file-changes]
83103 strategy :
@@ -164,6 +184,7 @@ jobs:
164184 run : bash pr/.github/scripts/run_parallel_benchmarks.sh ${{ matrix.device }} ${{ matrix.interface }} ${{ matrix.cluster }}
165185
166186 - name : Generate & Post Comment
187+ if : always()
167188 run : |
168189 (cd pr && . ./mfc.sh load -c ${{ matrix.flag }} -m g)
169190 (cd pr && ./mfc.sh bench_diff ../master/bench-${{ matrix.device }}-${{ matrix.interface }}.yaml ../pr/bench-${{ matrix.device }}-${{ matrix.interface }}.yaml)
0 commit comments