|
53 | 53 | publish_dir: ./_build/html/ |
54 | 54 | commit_message: ${{ github.event.head_commit.message }} |
55 | 55 |
|
| 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 | +
|
56 | 108 | deploy_notebooks: |
57 | 109 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
58 | 110 | name: Deploy deployed_notebook branch |
|
0 commit comments