[feature] Added issue autoassignment bots #757
[feature] Added issue autoassignment bots #757Eeshu-Yadav wants to merge 3 commits intoopenwisp:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (4)
📝 WalkthroughWalkthroughAdds four GitHub Actions workflows that invoke a reusable OpenWISP bot workflow to automate issue and PR management. New files:
Each workflow sets appropriate repo permissions, configures concurrency, and calls openwisp/openwisp-utils/.github/workflows/reusable-bot-autoassign.yml@master with a bot_command (issue_assignment, pr_reopen, stale_pr) and forwards OPENWISP_BOT_APP_ID and OPENWISP_BOT_PRIVATE_KEY via secrets. Sequence Diagram(s)sequenceDiagram
participant User
participant GitHubEvents as GitHub Events
participant Workflow as Repo Workflow
participant Reusable as openwisp-utils Reusable
participant GitHubApp as GitHub App (Bot)
participant Script as Bot Script
participant Repo as Repository (Issues/PRs)
User->>GitHubEvents: comment / open PR / reopen PR / cron
GitHubEvents->>Workflow: trigger corresponding workflow file
Workflow->>Reusable: invoke reusable-bot-autoassign.yml (bot_command)
Reusable->>GitHubApp: authenticate with OPENWISP_BOT_APP_ID & key
GitHubApp->>Reusable: return App token
Reusable->>Script: run bot command (issue_assignment / pr_reopen / stale_pr)
Script->>Repo: read/modify issues and PRs (assign/unassign/link)
Repo-->>User: updated issue/PR state
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Suggested reviewers
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces four new GitHub Actions workflows to automate issue and PR management (auto-assignment, PR–issue linking, PR reopen reassignment, and stale PR handling). Each workflow checks out openwisp/openwisp-utils to execute a shared bot Python script, ensuring consistent behavior across repositories.
Changes:
- Added
bot-autoassign-issue.yml: Listens forissue_commentevents on issues (not PRs) and runs theissue_assignmentbot command. - Added
bot-autoassign-pr-issue-link.yml: Triggers onpull_request_target(opened/reopened/closed) and runs theissue_assignmentbot command to manage PR–issue linking. - Added
bot-autoassign-pr-reopen.yml: Handles PR reopen and PR comment events with two jobs —reassign-on-reopenandhandle-pr-activity. - Added
bot-autoassign-stale-pr.yml: Runs on a daily schedule to manage stale PRs via thestale_prbot command.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
.github/workflows/bot-autoassign-issue.yml |
Autoassignment bot triggered by issue comments |
.github/workflows/bot-autoassign-pr-issue-link.yml |
Links issues to PRs when PRs are opened/closed/reopened |
.github/workflows/bot-autoassign-pr-reopen.yml |
Handles reassignment on PR reopen and PR comment activity |
.github/workflows/bot-autoassign-stale-pr.yml |
Daily scheduled job to manage stale PRs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| GITHUB_EVENT_NAME: ${{ github.event_name }} | ||
| run: > | ||
| python openwisp-utils/.github/actions/bot-autoassign/__main__.py | ||
| pr_reopen "$GITHUB_EVENT_PATH" |
There was a problem hiding this comment.
The handle-pr-activity job (triggered by issue_comment on a PR) calls the same pr_reopen command as the reassign-on-reopen job. These two jobs handle different events (a comment on a PR vs. a PR being reopened), so they should likely invoke different bot commands. If the intent is to handle PR activity from a comment (e.g., handling bot commands posted in a PR comment), this step should call a different subcommand rather than reusing pr_reopen. This appears to be a copy-paste error that will result in incorrect behavior when an issue_comment event fires on a PR.
| pr_reopen "$GITHUB_EVENT_PATH" | |
| pr_activity "$GITHUB_EVENT_PATH" |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/bot-autoassign-pr-issue-link.yml:
- Around line 3-5: These two workflows both trigger on pull_request_target
types: [reopened] (bot-autoassign-pr-issue-link.yml vs
bot-autoassign-pr-reopen.yml) and will run concurrently; either add a
top-of-file comment in both workflows explaining their distinct responsibilities
(issue_assignment vs pr_reopen) to make the concurrency intentional and safe, or
consolidate the reopened handling by removing the reopened event from one
workflow and routing its functionality into the other (or into distinct steps)
so only the intended subcommand runs on reopen, ensuring no overlap or duplicate
API calls.
In @.github/workflows/bot-autoassign-pr-reopen.yml:
- Around line 18-87: The two jobs reassign-on-reopen and handle-pr-activity
duplicate the same setup steps (Generate GitHub App token step id
generate-token, Checkout openwisp-utils, Set up Python, Install dependencies);
extract these into a reusable workflow or a composite action in openwisp-utils
(e.g., .github/workflows/reusable-setup.yml or .github/actions/composite-setup)
that performs the token creation, checkout, python setup and pip install, then
call that workflow/action from both jobs (and replace duplicates across other
workflow files) so each job simply invokes the shared step by name and passes
required inputs/outputs (GITHUB_TOKEN, REPOSITORY, etc.).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e358cfe2-c432-4d98-a2a1-11e4c4c7d685
📒 Files selected for processing (4)
.github/workflows/bot-autoassign-issue.yml.github/workflows/bot-autoassign-pr-issue-link.yml.github/workflows/bot-autoassign-pr-reopen.yml.github/workflows/bot-autoassign-stale-pr.yml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Agent
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
🔇 Additional comments (5)
.github/workflows/bot-autoassign-stale-pr.yml (1)
1-49: LGTM! Well-structured scheduled workflow.The workflow is correctly configured:
cancel-in-progress: falseis appropriate for scheduled jobs to prevent incomplete runs.- Permissions are properly scoped.
- Concurrency group prevents overlapping runs across repositories.
.github/workflows/bot-autoassign-issue.yml (1)
1-49: LGTM! Properly scoped issue comment handler.Key observations:
- The
if: github.event.issue.pull_request == nullcondition correctly ensures this workflow only processes comments on issues (not PRs), complementing thehandle-pr-activityjob inbot-autoassign-pr-reopen.yml.- Concurrency group keyed by issue number prevents race conditions.
- Permissions are minimal and appropriate.
.github/workflows/bot-autoassign-pr-issue-link.yml (1)
16-49: Security posture is appropriate forpull_request_target.The workflow correctly mitigates pwn request vulnerabilities by:
- Checking out
openwisp/openwisp-utils(a trusted repository) rather than the PR's potentially malicious code.- Running scripts only from the trusted
masterbranch.This is the safe pattern for
pull_request_targetworkflows..github/workflows/bot-autoassign-pr-reopen.yml (2)
14-16: Concurrency fallback handles both event types correctly.The expression
github.event.pull_request.number || github.event.issue.numbercorrectly resolves the identifier for bothpull_request_target(usespull_request.number) andissue_comment(usesissue.number) events.
54-56: Job condition correctly filters for PR comments only.The condition
github.event_name == 'issue_comment' && github.event.issue.pull_requestensures this job only handles comments on pull requests, complementing thebot-autoassign-issue.ymlworkflow which handles comments on regular issues with the inverse condition (github.event.issue.pull_request == null).
a37760b to
a5fe41e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/workflows/bot-autoassign-pr-issue-link.yml (1)
3-4:⚠️ Potential issue | 🟡 Minor
reopenedis still handled by two workflows, which can cause duplicate bot runs.Please either document strict separation of responsibilities or remove one
reopenedtrigger to avoid parallel execution on the same PR event.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/bot-autoassign-pr-issue-link.yml around lines 3 - 4, The workflow's pull_request_target trigger includes "reopened" which duplicates handling with another workflow and can cause duplicate bot runs; update the pull_request_target types array in this workflow (the entry with pull_request_target and types: [opened, reopened, closed]) to remove "reopened" (or alternatively remove "reopened" from the other conflicting workflow) so that only one workflow responds to reopened events, and document the separation in the workflow comment if you choose to keep both but split responsibilities.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/bot-autoassign-stale-pr.yml:
- Line 15: Replace the floating ref in the reusable workflow invocation by
pinning the uses statement to an immutable commit SHA: locate the uses line that
references
openwisp/openwisp-utils/.github/workflows/reusable-bot-autoassign.yml@master and
change the `@master` suffix to a specific commit SHA (e.g., @<commit-sha>) from
the openwisp-utils repo; ensure the chosen SHA corresponds to the intended
workflow version and update the workflow commit message to note the pinned SHA.
---
Duplicate comments:
In @.github/workflows/bot-autoassign-pr-issue-link.yml:
- Around line 3-4: The workflow's pull_request_target trigger includes
"reopened" which duplicates handling with another workflow and can cause
duplicate bot runs; update the pull_request_target types array in this workflow
(the entry with pull_request_target and types: [opened, reopened, closed]) to
remove "reopened" (or alternatively remove "reopened" from the other conflicting
workflow) so that only one workflow responds to reopened events, and document
the separation in the workflow comment if you choose to keep both but split
responsibilities.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 31cceb7d-4cd7-4dc0-8a35-f6fe82fc49b7
📒 Files selected for processing (4)
.github/workflows/bot-autoassign-issue.yml.github/workflows/bot-autoassign-pr-issue-link.yml.github/workflows/bot-autoassign-pr-reopen.yml.github/workflows/bot-autoassign-stale-pr.yml
📜 Review details
🔇 Additional comments (2)
.github/workflows/bot-autoassign-issue.yml (1)
13-13: Good guard to avoid PR comments in the issue-assignment workflow.The
ifcondition correctly limits this job to non-PR issues and avoids cross-trigger noise..github/workflows/bot-autoassign-pr-reopen.yml (1)
16-25: Job-level conditions are well scoped.The split conditions cleanly separate reopen handling from PR-author activity handling.
1cf4086 to
599e50a
Compare
|
▎ - bot-autoassign-pr-reopen.yml — the handle-pr-activity job runs on every comment the PR author posts on their own ▎ Rest of it looks fine — permissions are scoped correctly, concurrency groups make sense, and pull_request_target is |
Added GitHub Actions workflows to auto-assign issues, manage PR-issue linking, handle PR reopening reassignment, and manage stale PRs. Closes openwisp#756
Refines the caller workflows to use the updated `reusable-bot-autoassign.yml` from openwisp-utils. Reduces boilerplate, removes custom installations, and fixes bugs like the bot running on merged PRs.
Removes 'reopened' from the types on `bot-autoassign-pr-issue-link.yml`. The `bot-autoassign-pr-reopen.yml` already properly handles PR reopens, meaning this additional trigger was causing bot spam and race conditions.
599e50a to
80cb1a5
Compare
This PR adds the GitHub Actions workflows to auto-assign issues, manage PR-issue linking, handle PR reopening reassignment, and manage stale PRs.
These workflows check out
openwisp/openwisp-utilsto run the bot Python scripts, ensuring uniform behavior across all repositories.Related to the auto-assignment issue bot implementation.
closes #756