Skip to content

Commit 7972856

Browse files
committed
Run in separate workflow triggered on PR close
1 parent d4816ae commit 7972856

2 files changed

Lines changed: 50 additions & 28 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Post Merge Actions
2+
on:
3+
pull_request:
4+
types: [closed]
5+
6+
jobs:
7+
check-ci-and-notify:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/github-script@v8
11+
with:
12+
script: |
13+
const GRAALVMBOT_LOGIN = "Ariouz";
14+
const pr = context.payload.pull_request;
15+
if (!pr || !pr.number || pr.state !== "closed") return;
16+
17+
const author = pr.user;
18+
const assignees = pr.assignees || [];
19+
if (!author || author.login !== GRAALVMBOT_LOGIN) return;
20+
if (assignees.length !== 1) return;
21+
22+
const sha = pr.head.sha;
23+
24+
const runsResp = await github.rest.actions.listWorkflowRunsForRepo({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
head_sha: sha,
28+
event: "pull_request",
29+
per_page: 10
30+
});
31+
32+
const failedRun = runsResp.data.workflow_runs.find(run =>
33+
run.head_sha === sha &&
34+
run.status === "completed" &&
35+
run.conclusion !== "success"
36+
);
37+
38+
if (!failedRun) {
39+
console.log("No failed CI workflow found for the PR.");
40+
return;
41+
}
42+
43+
await github.rest.issues.createComment({
44+
issue_number: pr.number,
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
body: `@${assignees[0].login} - One or more CI jobs failed - [details](${failedRun.html_url}))`
48+
});
49+
console.log("CI failed, assignee notified.")

.github/workflows/ci-unittests.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,4 @@ jobs:
1818
needs: build-standalone-artifacts
1919
uses: ./.github/workflows/ci-matrix-gen.yml
2020
with:
21-
jobs_to_run: ^(?!python-svm-build|style).*-gate.*$
22-
23-
post-run:
24-
if: failure()
25-
needs: run-tests
26-
runs-on: ubuntu-latest
27-
steps:
28-
- uses: actions/github-script@v8
29-
with:
30-
script: |
31-
const GRAALVMBOT_LOGIN = "graalvmbot"
32-
var payload = context.payload
33-
if (!payload || !payload.number) return ;
34-
35-
var pr = payload.pull_request
36-
if (!pr || pr.state !== "closed") return ;
37-
38-
var author = pr.user
39-
var assignees = pr.assignees
40-
if (!author || author.login !== GRAALVMBOT_LOGIN) return ;
41-
if (!assignees || assignees.length != 1) return ;
42-
43-
github.rest.issues.createComment({
44-
issue_number: pr.number,
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
body: `@${assignees[0].login} - One or more CI jobs failed`
48-
})
21+
jobs_to_run: ^(?!python-svm-build|style).*-gate.*$

0 commit comments

Comments
 (0)