|
1 | 1 | name: 'Benchmark' |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - pull_request_review: |
6 | | - types: [submitted] |
| 4 | + # Trigger when Test Suite completes (no polling needed) |
| 5 | + workflow_run: |
| 6 | + workflows: ["Test Suite"] |
| 7 | + types: [completed] |
7 | 8 | workflow_dispatch: |
8 | 9 |
|
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
9 | 14 | jobs: |
10 | 15 | file-changes: |
11 | 16 | name: Detect File Changes |
| 17 | + # Only run if Test Suite passed (or manual dispatch) |
| 18 | + if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' |
12 | 19 | runs-on: 'ubuntu-latest' |
13 | | - outputs: |
| 20 | + outputs: |
14 | 21 | checkall: ${{ steps.changes.outputs.checkall }} |
| 22 | + pr_number: ${{ steps.pr-info.outputs.pr_number }} |
| 23 | + pr_approved: ${{ steps.pr-info.outputs.approved }} |
| 24 | + pr_author: ${{ steps.pr-info.outputs.author }} |
15 | 25 | steps: |
16 | 26 | - name: Clone |
17 | 27 | uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.workflow_run.head_sha || github.sha }} |
18 | 30 |
|
19 | 31 | - name: Detect Changes |
20 | 32 | uses: dorny/paths-filter@v3 |
21 | 33 | id: changes |
22 | | - with: |
| 34 | + with: |
23 | 35 | filters: ".github/file-filter.yml" |
24 | 36 |
|
| 37 | + - name: Get PR Info |
| 38 | + id: pr-info |
| 39 | + env: |
| 40 | + GH_TOKEN: ${{ github.token }} |
| 41 | + run: | |
| 42 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 43 | + echo "pr_number=" >> $GITHUB_OUTPUT |
| 44 | + echo "approved=true" >> $GITHUB_OUTPUT |
| 45 | + echo "author=${{ github.actor }}" >> $GITHUB_OUTPUT |
| 46 | + else |
| 47 | + # Get PR number from workflow_run |
| 48 | + PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}" |
| 49 | + if [ -n "$PR_NUMBER" ]; then |
| 50 | + echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT |
| 51 | +
|
| 52 | + # Fetch actual PR author from API (workflow_run.actor is the re-runner, not PR author) |
| 53 | + PR_AUTHOR=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER --jq '.user.login') |
| 54 | + echo "author=$PR_AUTHOR" >> $GITHUB_OUTPUT |
| 55 | +
|
| 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 |
| 64 | + else |
| 65 | + echo "pr_number=" >> $GITHUB_OUTPUT |
| 66 | + echo "approved=false" >> $GITHUB_OUTPUT |
| 67 | + echo "author=" >> $GITHUB_OUTPUT |
| 68 | + fi |
| 69 | + fi |
| 70 | +
|
25 | 71 | self: |
26 | 72 | name: "${{ matrix.name }} (${{ matrix.device }}${{ matrix.interface != 'none' && format('-{0}', matrix.interface) || '' }})" |
27 | | - if: ${{ github.repository=='MFlowCode/MFC' && needs.file-changes.outputs.checkall=='true' && ((github.event_name=='pull_request_review' && github.event.review.state=='approved') || (github.event_name=='pull_request' && (github.event.pull_request.user.login=='sbryngelson' || github.event.pull_request.user.login=='wilfonba'))) }} |
28 | | - needs: file-changes |
| 73 | + if: > |
| 74 | + github.repository == 'MFlowCode/MFC' && |
| 75 | + needs.file-changes.outputs.checkall == 'true' && |
| 76 | + ( |
| 77 | + github.event_name == 'workflow_dispatch' || |
| 78 | + needs.file-changes.outputs.pr_approved == 'true' || |
| 79 | + needs.file-changes.outputs.pr_author == 'sbryngelson' || |
| 80 | + needs.file-changes.outputs.pr_author == 'wilfonba' |
| 81 | + ) |
| 82 | + needs: [file-changes] |
29 | 83 | strategy: |
30 | 84 | fail-fast: false |
31 | 85 | matrix: |
|
89 | 143 | - name: Clone - PR |
90 | 144 | uses: actions/checkout@v4 |
91 | 145 | with: |
| 146 | + ref: ${{ github.event.workflow_run.head_sha || github.sha }} |
92 | 147 | path: pr |
93 | 148 |
|
94 | 149 | - name: Clone - Master |
|
0 commit comments