-
Notifications
You must be signed in to change notification settings - Fork 6
auto open issue on ci failure during release #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yaron2
merged 3 commits into
dapr:main
from
cicoyle:feat-auto-open-issues-on-release-failures
Jul 7, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # | ||
| # Copyright 2026 The Dapr Authors | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| # Reusable workflow that opens (or comments on) a tracking issue when a | ||
| # release/publish job fails. Call it from a job gated with `if: failure()` | ||
| # in the workflow that runs the release. The issue is opened in the calling | ||
| # repository (context.repo). To avoid duplicates, if an open issue with the | ||
| # same title already exists, a comment is added to it instead of opening a | ||
| # new one. | ||
|
|
||
| name: Open issue on failure | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| title: | ||
| required: true | ||
| type: string | ||
| description: Title of the issue to open. | ||
| body: | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| description: Extra context appended to the generated issue body. | ||
| labels: | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| description: Comma-separated list of labels to apply to the issue. | ||
| mention: | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| description: > | ||
| Space-separated @-handles or teams to mention in the issue body, | ||
| e.g. "@dapr/maintainers-dapr @dapr/approvers-dapr". | ||
| secrets: | ||
| dapr_bot_token: | ||
| required: false | ||
| description: > | ||
| Token used to author the issue. When omitted, the built-in | ||
| GITHUB_TOKEN is used (needs issues: write on the calling job). | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| open-issue: | ||
| name: Open issue on failure | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| issues: write | ||
| actions: read # to list the run's failed jobs and link to them | ||
| steps: | ||
| - uses: actions/github-script@v7 | ||
| env: | ||
| TITLE: ${{ inputs.title }} | ||
| EXTRA_BODY: ${{ inputs.body }} | ||
| LABELS: ${{ inputs.labels }} | ||
| MENTION: ${{ inputs.mention }} | ||
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
| WORKFLOW: ${{ github.workflow }} | ||
| REF: ${{ github.ref_name }} | ||
| SHA: ${{ github.sha }} | ||
| with: | ||
| github-token: ${{ secrets.dapr_bot_token || github.token }} | ||
| script: | | ||
| const { TITLE, EXTRA_BODY, LABELS, MENTION, RUN_URL, WORKFLOW, REF, SHA } = process.env; | ||
| const { owner, repo } = context.repo; | ||
| const labels = LABELS.split(',').map(l => l.trim()).filter(Boolean); | ||
| // Stable marker so we can re-find this issue even if the title changes. | ||
| const marker = `<!-- open-issue-on-failure:${TITLE} -->`; | ||
|
|
||
| // Reusable workflows share the caller's run_id, so this lists every | ||
| // job in the release run. Drives both the failed-job links and the | ||
| // "already retried" note. Empty on error (needs actions: read). | ||
|
cicoyle marked this conversation as resolved.
Outdated
|
||
| let failed = []; | ||
| try { | ||
| const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, { | ||
| owner, repo, run_id: context.runId, per_page: 100, | ||
| }); | ||
| failed = jobs.filter(j => ['failure', 'cancelled', 'timed_out'].includes(j.conclusion)); | ||
| } catch (e) { | ||
| core.warning(`Could not list failed jobs (needs actions: read): ${e.message}`); | ||
| } | ||
| const failedJobs = failed.length | ||
| ? ['', '**Failed jobs:**', ...failed.map(j => `- [${j.name}](${j.html_url})`)].join('\n') | ||
| : ''; | ||
|
|
||
| const runContext = [ | ||
| `- **Workflow run:** ${RUN_URL}`, | ||
| `- **Ref:** \`${REF}\``, | ||
| `- **Commit:** \`${SHA}\``, | ||
| ].join('\n'); | ||
|
|
||
| const issueBody = [ | ||
| MENTION.trim(), | ||
| `A release/publish job failed in **${WORKFLOW}**.`, | ||
| '', | ||
| runContext, | ||
|
cicoyle marked this conversation as resolved.
|
||
| failedJobs, | ||
| EXTRA_BODY.trim() && `\n${EXTRA_BODY.trim()}`, | ||
| '', | ||
| marker, | ||
| ].filter(Boolean).join('\n'); | ||
|
|
||
| // Dedup: find an existing open issue with the same title (or marker). | ||
| const open = await github.paginate(github.rest.issues.listForRepo, { | ||
| owner, | ||
| repo, | ||
| state: 'open', | ||
| labels: labels.join(',') || undefined, | ||
| per_page: 100, | ||
| }); | ||
|
cicoyle marked this conversation as resolved.
|
||
| const match = open.find(i => | ||
| !i.pull_request && (i.title === TITLE || (i.body || '').includes(marker))); | ||
|
|
||
| if (match) { | ||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: match.number, | ||
| body: [ | ||
| 'The release/publish job failed again.', | ||
| '', | ||
| runContext, | ||
| failedJobs, | ||
| ].filter(Boolean).join('\n'), | ||
| }); | ||
| core.notice(`Commented on existing issue #${match.number}`); | ||
| return; | ||
| } | ||
|
|
||
| const created = await github.rest.issues.create({ | ||
| owner, | ||
| repo, | ||
| title: TITLE, | ||
| body: issueBody, | ||
| labels, | ||
| }); | ||
| core.notice(`Opened issue #${created.data.number}`); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.