-
Notifications
You must be signed in to change notification settings - Fork 662
[Feature] Dependabot send out issue if package upgrade failure #3512
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
base: master
Are you sure you want to change the base?
Changes from all commits
e4ab607
f03d7f3
42d8419
b30ff5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| name: Dependabot Upgrade Monitor | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| monitor-dependabot: | ||
| if: github.event.pull_request.user.login == 'dependabot[bot]' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Wait for checks to complete | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will make sure all of the pipeline is finished before running this script |
||
| uses: WyriHaximus/github-action-wait-for-status@v1.8.0 | ||
| with: | ||
| ignoreActions: monitor-dependabot | ||
| checkInterval: 60 | ||
| env: | ||
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
|
||
| - name: Check if PR is failing | ||
| id: check | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const sha = context.payload.pull_request.head.sha; | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const { data: checkRunsData } = await github.rest.checks.listForRef({ | ||
| owner, | ||
| repo, | ||
| ref: sha, | ||
| }); | ||
| const checkRuns = checkRunsData.check_runs; | ||
| if (checkRuns.length === 0) { | ||
| core.setFailed("No status checks found for this PR."); | ||
| return; | ||
| } | ||
| const failedChecks = checkRuns.filter( | ||
| check => check.status === 'completed' && check.conclusion !== 'success' | ||
| ); | ||
| if (failedChecks.length > 0) { | ||
| console.log("Some checks failed:"); | ||
| failedChecks.forEach(check => { | ||
| console.log(`- ${check.name}: ${check.conclusion}`); | ||
| }); | ||
| core.setFailed("Some required checks did not pass."); | ||
| } else { | ||
| console.log("All checks passed."); | ||
| } | ||
| - name: Create issue on failure | ||
| if: failure() && github.event.action == 'opened' | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to ensure the bot won't spam the issue. |
||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| await github.rest.issues.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `Dependabot upgrade failed: #${context.issue.number} - ${context.payload.pull_request.title}`, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added the pr title |
||
| body: ` | ||
| 🚨 **Dependabot Upgrade Failed** | ||
|
|
||
| The following Dependabot pull request could not be merged automatically due to failed or incomplete status checks: | ||
|
|
||
| - **PR:** [#${context.issue.number}](${context.payload.pull_request.html_url}) | ||
| - **Status:** Not mergeable | ||
|
|
||
| Please review the PR and resolve any conflicts or CI issues to proceed with the upgrade.`, | ||
| labels: ["dependencies", "enhancement", "go"], | ||
| }); | ||
|
|
||
| - name: Assign maintainers on success | ||
| if: success() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const maintainers = ["dentiny", "kevin85421", "MortalHappiness", "rueian"]; | ||
| await github.rest.issues.addAssignees({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| assignees: maintainers, | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed
github.actortogithub.event.pull_request.user.loginReference