-
Notifications
You must be signed in to change notification settings - Fork 144
[ISSUE #1241]🔨Add Associate Milestone Github Action #1242
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
Conversation
WalkthroughA new GitHub Actions workflow named Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
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
|
🔊@mxsm 🚀Thanks for your contribution 🎉. CodeRabbit(AI) will review your code first 🔥 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1242 +/- ##
=======================================
Coverage 18.26% 18.26%
=======================================
Files 428 428
Lines 53595 53595
=======================================
Hits 9789 9789
Misses 43806 43806 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
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: 3
🧹 Outside diff range and nitpick comments (3)
.github/workflows/associate_milestone.yml (3)
3-6
: Consider expanding trigger events to include pull requestsThe workflow currently only triggers on new issues. Consider adding pull request events to ensure consistent milestone association across both issues and PRs.
on: issues: types: [ opened ] + pull_request: + types: [ opened ]
8-9
: Rename job to better reflect its purposeThe job name 'create-issue' is misleading as the job associates milestones with issues rather than creating issues.
jobs: - create-issue: + associate-milestone:
1-40
: Add newline at end of fileThe file is missing a newline character at the end, which is a POSIX requirement.
Add a newline character at the end of the file.
🧰 Tools
🪛 yamllint
[error] 1-1: wrong new line character: expected \n
(new-lines)
[error] 40-40: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/associate_milestone.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint
.github/workflows/associate_milestone.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
[error] 40-40: no new line character at the end of file
(new-line-at-end-of-file)
const milestones = await github.rest.issues.listMilestones({ | ||
owner, | ||
repo, | ||
}); |
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
Add error handling for API calls
The GitHub API calls lack proper error handling, which could make debugging issues difficult.
// Get the milestone ID by title
- const milestones = await github.rest.issues.listMilestones({
- owner,
- repo,
- });
+ try {
+ const milestones = await github.rest.issues.listMilestones({
+ owner,
+ repo,
+ });
+
+ const milestone = milestones.data.find(m => m.title === milestoneTitle);
+ if (!milestone) {
+ throw new Error(`Milestone with title "${milestoneTitle}" not found`);
+ }
+
+ await github.rest.issues.update({
+ owner,
+ repo,
+ issue_number: issueNumber,
+ milestone: milestone.number,
+ });
+
+ console.log(`Successfully associated issue #${issueNumber} with milestone "${milestoneTitle}"`);
+ } catch (error) {
+ core.setFailed(`Failed to associate milestone: ${error.message}`);
+ console.error('Full error:', error);
+ }
Also applies to: 33-38
- name: Associate Milestone | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.BOT_TOKEN }} |
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 using GITHUB_TOKEN instead of BOT_TOKEN
Using secrets.BOT_TOKEN
might be unnecessary as the default GITHUB_TOKEN
should have sufficient permissions for milestone association. Using a bot token could potentially expose broader permissions than needed.
- github-token: ${{ secrets.BOT_TOKEN }}
+ github-token: ${{ secrets.GITHUB_TOKEN }}
📝 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.
github-token: ${{ secrets.BOT_TOKEN }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} |
script: | | ||
const { owner, repo } = context.repo; | ||
const issueNumber = context.issue.number; | ||
const milestoneTitle = 'v0.4.0'; |
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
Make milestone title configurable
Hardcoding the milestone title 'v0.4.0' makes the workflow inflexible and requires code changes for each new version.
Consider making it configurable through workflow inputs:
name: Associate Milestone
+on:
+ workflow_dispatch:
+ inputs:
+ milestone_title:
+ description: 'Milestone to associate with new issues'
+ required: true
+ default: 'v0.4.0'
issues:
types: [ opened ]
...
- const milestoneTitle = 'v0.4.0';
+ const milestoneTitle = core.getInput('milestone_title');
Committable suggestion skipped: line range outside the PR's diff.
Which Issue(s) This PR Fixes(Closes)
Fixes #1241
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
This enhancement streamlines issue management by ensuring that relevant milestones are consistently applied to new issues, improving project tracking and organization.