-
Notifications
You must be signed in to change notification settings - Fork 29
feat: add GitHub Action to handle /assign and /unassign commands via issue comments #56
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: main
Are you sure you want to change the base?
Changes from all commits
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,83 @@ | ||||||||||||||||||
| name: Issue Commands | ||||||||||||||||||
|
|
||||||||||||||||||
| on: | ||||||||||||||||||
| issue_comment: | ||||||||||||||||||
| types: [created] | ||||||||||||||||||
|
|
||||||||||||||||||
| jobs: | ||||||||||||||||||
| issue_commands: | ||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||
| if: github.event.issue.pull_request == null && (startsWith(github.event.comment.body, '/assign') || startsWith(github.event.comment.body, '/unassign')) | ||||||||||||||||||
| steps: | ||||||||||||||||||
| - name: Handle Issue Commands | ||||||||||||||||||
| uses: actions/github-script@v6 | ||||||||||||||||||
|
||||||||||||||||||
| uses: actions/github-script@v6 | |
| uses: actions/github-script@v6.4.1 |
Copilot
AI
Apr 5, 2026
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.
The job-level if: runs when the comment starts with /assign or /unassign, but the script only handles exact matches (body === '/assign' / '/unassign'). Comments like /assign please or /assign\n... will trigger the workflow but then do nothing (no feedback). Consider parsing the first token/line in the script (or tightening the job condition) so the trigger condition and command handling are consistent.
Copilot
AI
Apr 5, 2026
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.
/unassign error handling only logs to the Actions output. If removeAssignees fails (e.g., commenter isn't assigned, lacks permission, or assignment is disabled for outside collaborators), the user gets no feedback. Consider posting an explanatory comment in the catch (similar to the /assign path) so the command isn't silently ignored.
| console.error(`Failed to unassign ${commenter}: ${error.message}`); | |
| console.error(`Failed to unassign ${commenter}: ${error.message}`); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| body: `Oops, @${commenter}! I couldn't unassign you from this issue. You might not currently be assigned, or you may not have the necessary permissions.` | |
| }); |
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.
The workflow doesn't declare explicit
permissions. On many repos the default GITHUB_TOKEN permissions are read-only, which will causeaddAssignees/removeAssignees/createCommentto fail. Please add least-privilege permissions (e.g.,permissions: issues: writeandcontents: readif needed) at the workflow or job level so this feature reliably works and limits token scope.