-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore: pr reminder for slack #21830
chore: pr reminder for slack #21830
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughA new GitHub Actions workflow named Changes
Sequence Diagram(s)sequenceDiagram
participant Scheduler
participant GitHub Actions
participant Slack
Scheduler->>GitHub Actions: Trigger workflow (daily at 9:00 AM UTC)
GitHub Actions->>GitHub: List open pull requests (not in draft)
GitHub Actions->>GitHub Actions: Construct summary table
alt If open PRs exist
GitHub Actions->>Slack: Send reminder with PR summary
end
📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
fc45071
to
288a221
Compare
288a221
to
8e22f54
Compare
968f1ce
to
8df596f
Compare
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.
Actionable comments posted: 4
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- .github/workflows/pr-reminder.yml (1 hunks)
Additional context used
actionlint
.github/workflows/pr-reminder.yml
19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
Additional comments not posted (2)
.github/workflows/pr-reminder.yml (2)
8-9
: LGTM: Appropriate permissions setThe permissions are correctly set to the minimum required (read access to pull requests) for this workflow's functionality. This adheres to the principle of least privilege, which is a good security practice.
1-54
: Overall assessment: Good implementation with room for improvementThis PR reminder workflow is well-structured and achieves its intended purpose. It effectively lists open pull requests and sends a reminder to a Slack channel. The use of GitHub Script for fetching PR data and the conditional execution of the Slack notification are particularly good practices.
However, there are several areas where the workflow can be improved:
- Removing the unnecessary pull request trigger
- Updating action versions to the latest available
- Fixing a typo in the PR summary
- Enhancing the Slack message with more context
By implementing the suggested changes, you'll have a more robust, up-to-date, and informative PR reminder workflow. Great job on setting this up, and thank you for your attention to improving the team's PR review process!
Tools
actionlint
19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
.github/workflows/pr-reminder.yml
Outdated
- name: Send Slack Reminder | ||
if: steps.pr-list.outputs.result != '' | ||
uses: rtCamp/[email protected] | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
SLACK_CHANNEL: pr-github | ||
SLACK_USERNAME: PR-Reminder | ||
SG_MINIMAL: true | ||
SLACK_ICON_EMOJI: ":think:" | ||
SLACK_COLOR: good | ||
SLACKIFY_MARKDOWN: true | ||
SLACK_TITLE: Daily Pull Request Review Reminder | ||
SLACK_MESSAGE: | | ||
${{ steps.pr-list.outputs.result }} |
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.
Enhance Slack notification step
The Slack notification step is well-structured, but there are a few improvements that could be made:
- The
rtCamp/action-slack-notify
action is not using the latest version. - The message could be enhanced with more context, such as the total number of open PRs.
Consider applying the following changes:
- Update the action version:
- uses: rtCamp/[email protected]
+ uses: rtCamp/[email protected]
- Enhance the message with more context:
SLACK_TITLE: Daily Pull Request Review Reminder
SLACK_MESSAGE: |
+ There are currently ${{ steps.pr-list.outputs.total }} open pull requests requiring review:
+
${{ steps.pr-list.outputs.result }}
- Add a step to count the total number of open PRs:
- name: Count open pull requests
id: pr-count
uses: actions/github-script@v7
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
draft: false
});
return pullRequests.length.toString();
- name: Send Slack Reminder
if: steps.pr-list.outputs.result != ''
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: pr-github
SLACK_USERNAME: PR-Reminder
SG_MINIMAL: true
SLACK_ICON_EMOJI: ":think:"
SLACK_COLOR: good
SLACKIFY_MARKDOWN: true
SLACK_TITLE: Daily Pull Request Review Reminder
SLACK_MESSAGE: |
There are currently ${{ steps.pr-count.outputs.result }} open pull requests requiring review:
${{ steps.pr-list.outputs.result }}
These changes will update the action to the latest version and provide more context in the Slack message, making it more informative for the team.
.github/workflows/pr-reminder.yml
Outdated
pr-review: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 |
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.
Update checkout action to the latest version
The job setup looks good, running on the latest Ubuntu version. However, the actions/checkout
action is using version 3, which is not the latest.
Consider updating to the latest version (v4) for potential improvements and bug fixes:
- name: Checkout repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
pr-review: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
pr-review: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 |
.github/workflows/pr-reminder.yml
Outdated
name: PR Review Reminder | ||
|
||
on: | ||
schedule: | ||
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC | ||
pull_request: |
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.
Consider removing the pull request trigger
The workflow name and schedule are well-defined. However, the pull request trigger (line 6) might be unnecessary for a reminder workflow that's intended to run on a schedule. Unless there's a specific reason to run the reminder immediately when a pull request is created or updated, consider removing this trigger to avoid potential noise or unnecessary executions.
You can remove the pull request trigger by applying this diff:
on:
schedule:
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC
- pull_request:
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
name: PR Review Reminder | |
on: | |
schedule: | |
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC | |
pull_request: | |
name: PR Review Reminder | |
on: | |
schedule: | |
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC |
1588446
to
44aedeb
Compare
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.
Actionable comments posted: 2
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- .github/workflows/pr-reminder.yml (1 hunks)
Additional context used
actionlint
.github/workflows/pr-reminder.yml
19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
Additional comments not posted (3)
.github/workflows/pr-reminder.yml (3)
1-6
: Consider removing the pull request triggerThe workflow name and schedule are well-defined. However, the pull request trigger (line 6) might be unnecessary for a reminder workflow that's intended to run on a schedule. Unless there's a specific reason to run the reminder immediately when a pull request is created or updated, consider removing this trigger to avoid potential noise or unnecessary executions.
8-9
: LGTM: Appropriate permissions setThe workflow correctly sets read-only permissions for pull requests, which is sufficient for listing open PRs without modifying them.
12-16
: Update checkout action to the latest versionThe job setup looks good, running on the latest Ubuntu version. However, the
actions/checkout
action is using version 3, which is not the latest.Consider updating to the latest version (v4) for potential improvements and bug fixes:
- name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4
.github/workflows/pr-reminder.yml
Outdated
- name: List open pull requests using GitHub Script | ||
uses: actions/github-script@v5 | ||
id: pr-list | ||
with: | ||
script: | | ||
const { data: pullRequests } = await github.rest.pulls.list({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
state: 'open', | ||
draft: false | ||
}); | ||
|
||
let table = ''; | ||
pullRequests.forEach(pr => { | ||
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees'; | ||
table += ` | ||
Title: ${pr.title} | ||
Link: <${pr.html_url}> | ||
Assigness: ${assignees} | ||
`; | ||
}); | ||
return table; | ||
|
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.
Update GitHub Script action and improve code quality
The GitHub Script step logic is correct, but there are several improvements to be made:
- Update the
actions/github-script
action to the latest version. - Fix the typo in the "Assignees" output.
- Improve the indentation in the table construction for better readability.
Apply the following changes:
- uses: actions/github-script@v5
+ uses: actions/github-script@v7
id: pr-list
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
draft: false
});
let table = '';
pullRequests.forEach(pr => {
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees';
table += `
- Title: ${pr.title}
- Link: <${pr.html_url}>
- Assigness: ${assignees}
- `;
+ Title: ${pr.title}
+ Link: <${pr.html_url}>
+ Assignees: ${assignees}
+
+ `;
});
return table;
These changes will update the action to the latest version, fix the typo, and improve the readability of the output.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: List open pull requests using GitHub Script | |
uses: actions/github-script@v5 | |
id: pr-list | |
with: | |
script: | | |
const { data: pullRequests } = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
draft: false | |
}); | |
let table = ''; | |
pullRequests.forEach(pr => { | |
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees'; | |
table += ` | |
Title: ${pr.title} | |
Link: <${pr.html_url}> | |
Assigness: ${assignees} | |
`; | |
}); | |
return table; | |
- name: List open pull requests using GitHub Script | |
uses: actions/github-script@v7 | |
id: pr-list | |
with: | |
script: | | |
const { data: pullRequests } = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
draft: false | |
}); | |
let table = ''; | |
pullRequests.forEach(pr => { | |
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees'; | |
table += ` | |
Title: ${pr.title} | |
Link: <${pr.html_url}> | |
Assignees: ${assignees} | |
`; | |
}); | |
return table; |
Tools
actionlint
19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
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.
Actionable comments posted: 2
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- .github/workflows/pr-reminder.yml (1 hunks)
Additional context used
actionlint
.github/workflows/pr-reminder.yml
18-18: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
Additional comments not posted (2)
.github/workflows/pr-reminder.yml (2)
1-5
: LGTM: Workflow name and trigger are well-definedThe workflow name accurately describes its purpose, and the schedule is appropriate for a daily reminder during the work week. The pull request trigger has been removed, which is correct for this type of reminder workflow.
17-39
:⚠️ Potential issueUpdate GitHub Script action and improve code quality
The GitHub Script step logic is correct, but there are several improvements to be made:
- Update the
actions/github-script
action to the latest version.- Fix the typo in the "Assignees" output.
- Improve the indentation in the table construction for better readability.
Apply the following changes:
- uses: actions/github-script@v5 + uses: actions/github-script@v7 id: pr-list with: script: | const { data: pullRequests } = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, state: 'open', draft: false }); let table = ''; pullRequests.forEach(pr => { const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees'; table += ` - Title: ${pr.title} - Link: <${pr.html_url}> - Assigness: ${assignees} - `; + Title: ${pr.title} + Link: <${pr.html_url}> + Assignees: ${assignees} + + `; }); return table;These changes will update the action to the latest version, fix the typo, and improve the readability of the output.
Regarding the comment about draft PRs being included, let's verify if the filter is working correctly:
If you'd like to skip PRs without assignees, we can discuss adding this feature. It would require modifying the script to filter out PRs without assignees before adding them to the table.
Verification successful
Draft PRs are correctly excluded from the list
The
pr-reminder.yml
workflow properly excludes draft pull requests by settingdraft: false
in the GitHub API call. No draft PRs are included in the listed reminders.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that draft PRs are excluded from the list # Test: Search for the draft filter in the GitHub API call rg --type yaml 'draft: false' .github/workflows/pr-reminder.yml # Test: Check if there are any occurrences where draft PRs might be included rg --type yaml 'draft: true' .github/workflows/pr-reminder.ymlLength of output: 157
Tools
actionlint
18-18: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
.github/workflows/pr-reminder.yml
Outdated
- name: Send Slack Reminder | ||
if: steps.pr-list.outputs.result != '' | ||
uses: rtCamp/[email protected] | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
SLACK_CHANNEL: pr-github | ||
SLACK_USERNAME: PR-Reminder | ||
MSG_MINIMAL: true | ||
SLACK_ICON_EMOJI: ":think:" | ||
SLACK_COLOR: good | ||
SLACKIFY_MARKDOWN: true | ||
SLACK_TITLE: Daily Pull Request Review Reminder | ||
SLACK_MESSAGE: | | ||
${{ steps.pr-list.outputs.result }} |
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.
Enhance Slack notification step
The Slack notification step needs some improvements:
- Update the
rtCamp/action-slack-notify
action to the latest stable version. - Fix the environment variable name for minimal output.
- Enhance the message with more context, such as the total number of open PRs.
Apply the following changes:
- Update the action version:
- uses: rtCamp/[email protected]
+ uses: rtCamp/[email protected]
- Fix the environment variable name:
- MSG_MINIMAL: true
+ SG_MINIMAL: true
- Add a step to count the total number of open PRs and enhance the message:
- name: Count open pull requests
id: pr-count
uses: actions/github-script@v7
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
draft: false
});
return pullRequests.length.toString();
- name: Send Slack Reminder
if: steps.pr-list.outputs.result != ''
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: pr-github
SLACK_USERNAME: PR-Reminder
SG_MINIMAL: true
SLACK_ICON_EMOJI: ":think:"
SLACK_COLOR: good
SLACKIFY_MARKDOWN: true
SLACK_TITLE: Daily Pull Request Review Reminder
SLACK_MESSAGE: |
There are currently ${{ steps.pr-count.outputs.result }} open pull requests requiring review:
${{ steps.pr-list.outputs.result }}
These changes will update the action to the latest stable version, fix the environment variable name, and provide more context in the Slack message, making it more informative for the team.
.github/workflows/pr-reminder.yml
Outdated
permissions: | ||
pull-requests: read | ||
|
||
jobs: | ||
pr-review: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 |
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.
🛠️ Refactor suggestion
Update checkout action to the latest version
The job setup and permissions look good. However, consider updating the actions/checkout
action to the latest version for potential improvements and bug fixes:
- name: Checkout repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
permissions: | |
pull-requests: read | |
jobs: | |
pr-review: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
permissions: | |
pull-requests: read | |
jobs: | |
pr-review: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 |
c4005a0
to
67c77e0
Compare
Description
testing a pr reminder for open prs on github
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit