|
1 | 1 | name: "Build" |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - branches: [ main ] |
| 4 | + issue_comment: |
| 5 | + types: [created] |
6 | 6 |
|
7 | 7 | jobs: |
| 8 | + trigger-comment: |
| 9 | + if: github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test') |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: "Post trigger comment" |
| 13 | + uses: actions/github-script@v7 |
| 14 | + with: |
| 15 | + script: | |
| 16 | + const workflowUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`; |
| 17 | + github.rest.issues.createComment({ |
| 18 | + issue_number: context.issue.number, |
| 19 | + owner: context.repo.owner, |
| 20 | + repo: context.repo.repo, |
| 21 | + body: `🚀 Build workflow triggered! [View run](${workflowUrl})` |
| 22 | + }); |
| 23 | +
|
8 | 24 | build: |
| 25 | + needs: trigger-comment |
| 26 | + if: github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test') |
9 | 27 | strategy: |
10 | 28 | matrix: |
11 | 29 | include: |
|
22 | 40 | image: ${{ matrix.image }} |
23 | 41 |
|
24 | 42 | steps: |
25 | | - - name: "Checkout code" |
| 43 | + - name: "Free disk space" |
| 44 | + run: | |
| 45 | + sudo rm -rf /usr/local/lib/android || true |
| 46 | + sudo rm -rf /usr/share/dotnet || true |
| 47 | +
|
| 48 | + - name: "Retrieve PR info" |
| 49 | + uses: actions/github-script@v7 |
| 50 | + id: pr-info |
| 51 | + with: |
| 52 | + script: | |
| 53 | + const pr = await github.rest.pulls.get({ |
| 54 | + owner: context.repo.owner, |
| 55 | + repo: context.repo.repo, |
| 56 | + pull_number: context.issue.number |
| 57 | + }); |
| 58 | + core.setOutput('sha', pr.data.head.sha); |
| 59 | +
|
| 60 | + - name: "Checkout PR code" |
26 | 61 | uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + ref: ${{ steps.pr-info.outputs.sha }} |
27 | 64 |
|
28 | 65 | - name: "Full build with NVSHMEM" |
29 | 66 | run: | |
|
38 | 75 | cd build-no-nvshmem |
39 | 76 | cmake .. |
40 | 77 | make -j$(nproc) |
| 78 | +
|
| 79 | + result-comment: |
| 80 | + needs: build |
| 81 | + if: always() && github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test') |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - name: "Post result comment" |
| 85 | + uses: actions/github-script@v7 |
| 86 | + with: |
| 87 | + script: | |
| 88 | + const workflowUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`; |
| 89 | + const success = '${{ needs.build.result }}' === 'success'; |
| 90 | +
|
| 91 | + const message = success |
| 92 | + ? `✅ Build workflow passed! [View run](${workflowUrl})` |
| 93 | + : `❌ Build workflow failed! [View run](${workflowUrl})`; |
| 94 | +
|
| 95 | + github.rest.issues.createComment({ |
| 96 | + issue_number: context.issue.number, |
| 97 | + owner: context.repo.owner, |
| 98 | + repo: context.repo.repo, |
| 99 | + body: message |
| 100 | + }); |
0 commit comments