Post comment on workflow run ready (#224)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
name: Examples - APO
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 3 AM UTC+8
|
||||
@@ -12,6 +13,18 @@ on:
|
||||
types: [ci-apo, ci-all]
|
||||
|
||||
jobs:
|
||||
dispatch-notify:
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const dispatchComment = require('./scripts/dispatch_comment.js');
|
||||
await dispatchComment({ core, github, context });
|
||||
|
||||
apo:
|
||||
if: >
|
||||
github.event_name != 'repository_dispatch' ||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: Examples - Calc-X
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 3 AM UTC+8
|
||||
@@ -12,6 +13,18 @@ on:
|
||||
types: [ci-calc-x, ci-all]
|
||||
|
||||
jobs:
|
||||
dispatch-notify:
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const dispatchComment = require('./scripts/dispatch_comment.js');
|
||||
await dispatchComment({ core, github, context });
|
||||
|
||||
calc-x:
|
||||
if: >
|
||||
github.event_name != 'repository_dispatch' ||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: Examples - Backward Compatibility
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 6 AM UTC+8
|
||||
@@ -12,6 +13,18 @@ on:
|
||||
types: [ci-compat, ci-all]
|
||||
|
||||
jobs:
|
||||
dispatch-notify:
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const dispatchComment = require('./scripts/dispatch_comment.js');
|
||||
await dispatchComment({ core, github, context });
|
||||
|
||||
backward-compatibility:
|
||||
if: >
|
||||
github.event_name != 'repository_dispatch' ||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: Examples - Spider
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 4 AM UTC+8
|
||||
@@ -12,6 +13,18 @@ on:
|
||||
types: [ci-spider, ci-all]
|
||||
|
||||
jobs:
|
||||
dispatch-notify:
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const dispatchComment = require('./scripts/dispatch_comment.js');
|
||||
await dispatchComment({ core, github, context });
|
||||
|
||||
spider:
|
||||
if: >
|
||||
github.event_name != 'repository_dispatch' ||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: Examples - Unsloth
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 5 AM UTC+8
|
||||
@@ -12,6 +13,18 @@ on:
|
||||
types: [ci-unsloth, ci-all]
|
||||
|
||||
jobs:
|
||||
dispatch-notify:
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const dispatchComment = require('./scripts/dispatch_comment.js');
|
||||
await dispatchComment({ core, github, context });
|
||||
|
||||
unsloth:
|
||||
if: >
|
||||
github.event_name != 'repository_dispatch' ||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
name: GPU Test
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 5 AM UTC+8
|
||||
@@ -12,6 +13,18 @@ on:
|
||||
types: [ci-unsloth, ci-all]
|
||||
|
||||
jobs:
|
||||
dispatch-notify:
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const dispatchComment = require('./scripts/dispatch_comment.js');
|
||||
await dispatchComment({ core, github, context });
|
||||
|
||||
tests-full:
|
||||
if: >
|
||||
github.event_name != 'repository_dispatch' ||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
module.exports = async function dispatchComment({ core, github, context }) {
|
||||
const payload = context.payload.client_payload || {};
|
||||
const pullNumber = payload.pull_number;
|
||||
|
||||
if (!pullNumber) {
|
||||
core.notice(
|
||||
"No pull_number found in repository_dispatch payload; skipping comment."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const { owner, repo } = context.repo;
|
||||
const action =
|
||||
context.payload.action || payload.ci_label || context.eventName || "dispatch";
|
||||
const runId = process.env.GITHUB_RUN_ID;
|
||||
const workflowName = context.workflow || "Workflow";
|
||||
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`;
|
||||
|
||||
const body = `🚀 ${workflowName} dispatched via \`${action}\`. Track progress here: ${runUrl}`;
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: pullNumber,
|
||||
body,
|
||||
});
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
module.exports = function triggerOnLabel({ core, context, labelName }) {
|
||||
if (!labelName) {
|
||||
throw new Error("labelName is required");
|
||||
}
|
||||
|
||||
if (context.eventName !== "pull_request_target") {
|
||||
core.setOutput("should-run", "true");
|
||||
core.notice("Triggering this workflow because event is not a pull request");
|
||||
return;
|
||||
}
|
||||
|
||||
core.notice(`This workflow is triggered by ${context.eventName}`);
|
||||
|
||||
const labels = (context.payload.pull_request?.labels ?? []).map(
|
||||
(label) => label.name
|
||||
);
|
||||
core.notice(`Pull request labels: ${labels.join(", ")}`);
|
||||
|
||||
if (labels.includes(labelName)) {
|
||||
core.setOutput("should-run", "true");
|
||||
core.notice(
|
||||
`Triggering this workflow because pull request has the '${labelName}' label.`
|
||||
);
|
||||
} else if (labels.includes("ci-all")) {
|
||||
core.setOutput("should-run", "true");
|
||||
core.notice(
|
||||
`Triggering this workflow because pull request has the 'ci-all' label.`
|
||||
);
|
||||
} else {
|
||||
core.setOutput("should-run", "false");
|
||||
core.notice(
|
||||
`Skipping because pull request is missing the '${labelName}' label.`
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user