Skip to content

Commit e15bb92

Browse files
committed
Update build CI to trigger on comment. Free up additional runner disk space at start of workflow.
1 parent 12c1bb8 commit e15bb92

File tree

1 file changed

+63
-3
lines changed

1 file changed

+63
-3
lines changed

.github/workflows/build.yml

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
name: "Build"
22

33
on:
4-
pull_request:
5-
branches: [ main ]
4+
issue_comment:
5+
types: [created]
66

77
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+
824
build:
25+
needs: trigger-comment
26+
if: github.event.issue.pull_request && contains(github.event.comment.body, '/build_and_test')
927
strategy:
1028
matrix:
1129
include:
@@ -22,8 +40,27 @@ jobs:
2240
image: ${{ matrix.image }}
2341

2442
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"
2661
uses: actions/checkout@v4
62+
with:
63+
ref: ${{ steps.pr-info.outputs.sha }}
2764

2865
- name: "Full build with NVSHMEM"
2966
run: |
@@ -38,3 +75,26 @@ jobs:
3875
cd build-no-nvshmem
3976
cmake ..
4077
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

Comments
 (0)