|
1 | 1 | name: Add Dogfooding Comment |
2 | 2 |
|
3 | 3 | on: |
4 | | - # Use pull_request_target to run in the context of the base branch |
5 | | - # This allows commenting on PRs from forks |
6 | | - pull_request_target: |
7 | | - types: [opened, reopened, synchronize] |
8 | | - branches: |
9 | | - - 'main' |
10 | | - - 'net*' |
11 | | - - 'release/**' |
| 4 | + # Trigger when the maui-pr build check completes |
| 5 | + check_run: |
| 6 | + types: [completed] |
12 | 7 |
|
13 | 8 | # Allow manual triggering |
14 | 9 | workflow_dispatch: |
|
20 | 15 |
|
21 | 16 | # Ensure only one instance runs at a time per PR to prevent duplicate comments |
22 | 17 | concurrency: |
23 | | - group: dogfood-comment-${{ github.event.pull_request.number || github.event.inputs.pr_number }} |
| 18 | + group: dogfood-comment-${{ github.event.check_run.pull_requests[0].number || github.event.inputs.pr_number || 'unknown' }} |
24 | 19 | cancel-in-progress: true |
25 | 20 |
|
26 | 21 | jobs: |
27 | 22 | add-dogfood-comment: |
28 | | - # Only run on the dotnet org to avoid running on forks |
29 | | - if: ${{ github.repository_owner == 'dotnet' }} |
| 23 | + # Only run on the dotnet org, for the maui-pr check, when it completes successfully |
| 24 | + if: | |
| 25 | + github.repository_owner == 'dotnet' && |
| 26 | + ( |
| 27 | + github.event_name == 'workflow_dispatch' || |
| 28 | + ( |
| 29 | + github.event_name == 'check_run' && |
| 30 | + github.event.check_run.name == 'maui-pr (Pack .NET MAUI Pack Windows)' && |
| 31 | + github.event.check_run.conclusion == 'success' && |
| 32 | + github.event.check_run.pull_requests[0] != null |
| 33 | + ) |
| 34 | + ) |
30 | 35 | runs-on: ubuntu-latest |
31 | 36 | permissions: |
32 | 37 | pull-requests: write |
|
36 | 41 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
37 | 42 | with: |
38 | 43 | script: | |
39 | | - // Get PR number from either the PR event or manual input |
40 | | - const prNumber = context.payload.number || context.payload.inputs?.pr_number; |
| 44 | + // Get PR number from either the check_run event or manual input |
| 45 | + const prNumber = context.payload.check_run?.pull_requests?.[0]?.number || context.payload.inputs?.pr_number; |
41 | 46 |
|
42 | 47 | const bashScript = 'https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh'; |
43 | 48 | const psScript = 'https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1'; |
|
0 commit comments