Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/dependabot-notifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Dependabot Upgrade Monitor

on:
pull_request:
types: [opened, synchronize]

jobs:
monitor-dependabot:
if: github.event.pull_request.user.login == 'dependabot[bot]'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed github.actor to github.event.pull_request.user.login
Reference

runs-on: ubuntu-latest
steps:
- name: Wait for checks to complete
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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}`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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: |
// Step 1: Get collaborators
const collaborators = await github.paginate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: do we issue one request or multiple requests, if the overall collaborator numbers are >100?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will automatically issue multiple requests if there are more than 100 collaborators.

github.rest.repos.listCollaborators,
{
owner: context.repo.owner,
repo: context.repo.repo,
affiliation: 'direct',
per_page: 100
}
);

// Step 2: Filter maintainers
const maintainers = collaborators
.filter(user => user.permissions.admin)
.map(user => user.login);

// Step 3: Assign to the PR
if (maintainers.length > 0) {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: maintainers,
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will assign all of the maintainers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious as of now, who will be assigned?

Copy link
Collaborator Author

@CheyuWu CheyuWu May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user.permissions.admin =>["ericl","pcmoritz","richardliaw","Jeffwan","zhe-thoughts"]`

Well, I should assign the reviewer directly, not via the API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also try user.permissions.pusher and user.permission.maintainer.
The result is

Pusher:  [
  'ericl',
  'pcmoritz',
  'caitengwei',
  'wilsonwang371',
  'richardliaw',
  'Jeffwan',
  'zhe-thoughts',
  'andrewsykim',
  'akanso',
  'simon-mo',
  'DmitriGekhtman',
  'sriram-anyscale'
]
Maintainers:  [
  'ericl',
  'pcmoritz',
  'caitengwei',
  'richardliaw',
  'Jeffwan',
  'zhe-thoughts',
  'akanso',
  'simon-mo',
  'DmitriGekhtman'
]

https://github.com/ray-project/kuberay/actions/runs/14836955695/job/41650311396?pr=3544

} else {
console.warn("No maintainers found to assign.");
}
Loading