Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,44 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

# Notify on job failure
notify-on-failure:
runs-on: ubuntu-latest
needs:
- allgreen
if: ${{ needs.allgreen.result == 'failure' }}
steps:
- name: Create or update failure issue
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;

// Reuse a single issue to avoid spam
const search = await github.rest.search.issuesAndPullRequests({
q: `repo:${owner}/${repo} is:issue is:open "Scheduled CI job failed"`
});
const body = [
`### Nightly CI job failed`,
`- Workflow: **${process.env.GITHUB_WORKFLOW}**`,
`- Run: ${context.runId}`,
`- Commit: ${process.env.GITHUB_SHA}`,
`- Branch/Ref: ${process.env.GITHUB_REF}`,
`- URL: https://github.com/${owner}/${repo}/actions/runs/${context.runId}`,
``,
`Please investigate and close this issue once fixed.`
].join("\n");

if (search.data.items.length > 0) {
const issue = search.data.items[0];
await github.rest.issues.createComment({
owner, repo, issue_number: issue.number, body
});
} else {
await github.rest.issues.create({
owner, repo,
title: "Scheduled CI job failed",
body,
});
}
Loading