Skip to content

Commit 0aad4d0

Browse files
committed
Open an issue if Publish HTML fails
1 parent f3c988b commit 0aad4d0

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/ci_publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,58 @@ jobs:
5353
publish_dir: ./_build/html/
5454
commit_message: ${{ github.event.head_commit.message }}
5555

56+
- name: Create issue or comment if run fails
57+
if: failure()
58+
uses: actions/github-script@v7
59+
with:
60+
script: |
61+
const title = `❌ Job failed: ${context.job} Run #${context.runNumber}`;
62+
63+
// Search for existing open issue with the same title
64+
const issues = await github.rest.issues.listForRepo({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
state: 'open',
68+
labels: 'workflow-failure',
69+
per_page: 100
70+
});
71+
72+
const existingIssue = issues.data.find(issue => issue.title === title);
73+
74+
const body = `## Job Failed
75+
76+
**Job:** ${context.job}
77+
**Workflow:** ${context.workflow}
78+
**Event:** ${context.eventName}
79+
**Run ID:** ${context.runId}
80+
**Run Number:** ${context.runNumber}
81+
**Run Attempt:** ${context.runAttempt}
82+
**Ref:** ${context.ref}
83+
**Ref Name:** ${context.refName}
84+
**SHA:** ${context.sha}
85+
**Short SHA:** ${context.sha.substring(0, 7)}
86+
87+
[View run details](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`;
88+
89+
if (existingIssue) {
90+
// Add comment to existing issue (for retry attempts)
91+
await github.rest.issues.createComment({
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
issue_number: existingIssue.number,
95+
body: body
96+
});
97+
} else {
98+
// Create new issue
99+
await github.rest.issues.create({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
title: title,
103+
body: body,
104+
labels: ['workflow-failure']
105+
});
106+
}
107+
56108
deploy_notebooks:
57109
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
58110
name: Deploy deployed_notebook branch

0 commit comments

Comments
 (0)