Skip to content

Commit 3966db6

Browse files
authored
Post comment on workflow run ready (#224)
1 parent 584600d commit 3966db6

File tree

8 files changed

+107
-37
lines changed

8 files changed

+107
-37
lines changed

.github/workflows/examples-apo.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Examples - APO
22
permissions:
33
contents: read
4+
issues: write
45
on:
56
schedule:
67
# Every day at 3 AM UTC+8
@@ -12,6 +13,18 @@ on:
1213
types: [ci-apo, ci-all]
1314

1415
jobs:
16+
dispatch-notify:
17+
if: github.event_name == 'repository_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Comment with workflow run link
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const dispatchComment = require('./scripts/dispatch_comment.js');
26+
await dispatchComment({ core, github, context });
27+
1528
apo:
1629
if: >
1730
github.event_name != 'repository_dispatch' ||

.github/workflows/examples-calc-x.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Examples - Calc-X
22
permissions:
33
contents: read
4+
issues: write
45
on:
56
schedule:
67
# Every day at 3 AM UTC+8
@@ -12,6 +13,18 @@ on:
1213
types: [ci-calc-x, ci-all]
1314

1415
jobs:
16+
dispatch-notify:
17+
if: github.event_name == 'repository_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Comment with workflow run link
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const dispatchComment = require('./scripts/dispatch_comment.js');
26+
await dispatchComment({ core, github, context });
27+
1528
calc-x:
1629
if: >
1730
github.event_name != 'repository_dispatch' ||

.github/workflows/examples-compat.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Examples - Backward Compatibility
22
permissions:
33
contents: read
4+
issues: write
45
on:
56
schedule:
67
# Every day at 6 AM UTC+8
@@ -12,6 +13,18 @@ on:
1213
types: [ci-compat, ci-all]
1314

1415
jobs:
16+
dispatch-notify:
17+
if: github.event_name == 'repository_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Comment with workflow run link
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const dispatchComment = require('./scripts/dispatch_comment.js');
26+
await dispatchComment({ core, github, context });
27+
1528
backward-compatibility:
1629
if: >
1730
github.event_name != 'repository_dispatch' ||

.github/workflows/examples-spider.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Examples - Spider
22
permissions:
33
contents: read
4+
issues: write
45
on:
56
schedule:
67
# Every day at 4 AM UTC+8
@@ -12,6 +13,18 @@ on:
1213
types: [ci-spider, ci-all]
1314

1415
jobs:
16+
dispatch-notify:
17+
if: github.event_name == 'repository_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Comment with workflow run link
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const dispatchComment = require('./scripts/dispatch_comment.js');
26+
await dispatchComment({ core, github, context });
27+
1528
spider:
1629
if: >
1730
github.event_name != 'repository_dispatch' ||

.github/workflows/examples-unsloth.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Examples - Unsloth
22
permissions:
33
contents: read
4+
issues: write
45
on:
56
schedule:
67
# Every day at 5 AM UTC+8
@@ -12,6 +13,18 @@ on:
1213
types: [ci-unsloth, ci-all]
1314

1415
jobs:
16+
dispatch-notify:
17+
if: github.event_name == 'repository_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Comment with workflow run link
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const dispatchComment = require('./scripts/dispatch_comment.js');
26+
await dispatchComment({ core, github, context });
27+
1528
unsloth:
1629
if: >
1730
github.event_name != 'repository_dispatch' ||

.github/workflows/tests-full.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: GPU Test
22
permissions:
33
contents: read
4+
issues: write
45
on:
56
schedule:
67
# Every day at 5 AM UTC+8
@@ -12,6 +13,18 @@ on:
1213
types: [ci-unsloth, ci-all]
1314

1415
jobs:
16+
dispatch-notify:
17+
if: github.event_name == 'repository_dispatch'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Comment with workflow run link
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const dispatchComment = require('./scripts/dispatch_comment.js');
26+
await dispatchComment({ core, github, context });
27+
1528
tests-full:
1629
if: >
1730
github.event_name != 'repository_dispatch' ||

scripts/dispatch_comment.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
module.exports = async function dispatchComment({ core, github, context }) {
4+
const payload = context.payload.client_payload || {};
5+
const pullNumber = payload.pull_number;
6+
7+
if (!pullNumber) {
8+
core.notice(
9+
"No pull_number found in repository_dispatch payload; skipping comment."
10+
);
11+
return;
12+
}
13+
14+
const { owner, repo } = context.repo;
15+
const action =
16+
context.payload.action || payload.ci_label || context.eventName || "dispatch";
17+
const runId = process.env.GITHUB_RUN_ID;
18+
const workflowName = context.workflow || "Workflow";
19+
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`;
20+
21+
const body = `🚀 ${workflowName} dispatched via \`${action}\`. Track progress here: ${runUrl}`;
22+
23+
await github.rest.issues.createComment({
24+
owner,
25+
repo,
26+
issue_number: pullNumber,
27+
body,
28+
});
29+
};

scripts/trigger_on_label.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)