release-failure-alert #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release-failure-alert | |
| on: | |
| workflow_run: | |
| workflows: ["release"] | |
| types: [completed] | |
| jobs: | |
| create-alert: | |
| if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| steps: | |
| - name: Create release failure alert issue | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const run = context.payload.workflow_run; | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const runId = String(run.id); | |
| const title = `[release-alert] release workflow run ${runId} failed`; | |
| const query = `repo:${owner}/${repo} is:issue is:open in:title "${title}"`; | |
| const existing = await github.rest.search.issuesAndPullRequests({ q: query }); | |
| if (existing.data.total_count > 0) { | |
| core.info(`Existing alert issue already open for run ${runId}`); | |
| return; | |
| } | |
| const body = [ | |
| "Release workflow reported a failure.", | |
| "", | |
| `- Workflow run: ${run.html_url}`, | |
| `- Event: ${run.event}`, | |
| `- Ref: ${run.head_branch || run.head_sha}`, | |
| `- SHA: ${run.head_sha}`, | |
| `- Triggered by: ${run.actor?.login || "unknown"}`, | |
| `- Conclusion: ${run.conclusion}`, | |
| "", | |
| "Action: inspect failed jobs (artifact build/publish/verification) and apply runbook rollback/retry steps." | |
| ].join("\n"); | |
| await github.rest.issues.create({ | |
| owner, | |
| repo, | |
| title, | |
| body | |
| }); |