-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ci: add /assign self-service issue-claim bot #1026
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: develop
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,39 @@ | ||
| name: Self-assign issues | ||
|
|
||
| # Lets community contributors and interns claim issues WITHOUT being granted | ||
| # write/triage: commenting "/assign" on an issue assigns the commenter, | ||
| # "/unassign" removes them. The workflow's GITHUB_TOKEN performs the | ||
| # assignment, so no per-person role hand-out is needed for self-service | ||
| # claiming. (Requested by Josh — pairs with the fork-and-PR contribution | ||
| # model.) | ||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| permissions: | ||
| issues: write | ||
|
|
||
| jobs: | ||
| assign: | ||
| # Only on issues (not PR comments), and only for the /assign|/unassign verbs. | ||
| if: >- | ||
| ${{ !github.event.issue.pull_request && | ||
| (startsWith(github.event.comment.body, '/assign') || | ||
| startsWith(github.event.comment.body, '/unassign')) }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 | ||
| with: | ||
| script: | | ||
| const { owner, repo } = context.repo; | ||
| const issue_number = context.issue.number; | ||
| const user = context.payload.comment.user.login; | ||
| const unassign = context.payload.comment.body.trim().startsWith('/unassign'); | ||
| if (unassign) { | ||
| await github.rest.issues.removeAssignees({ owner, repo, issue_number, assignees: [user] }); | ||
| } else { | ||
| await github.rest.issues.addAssignees({ owner, repo, issue_number, assignees: [user] }); | ||
| } | ||
| await github.rest.reactions.createForIssueComment({ | ||
| owner, repo, comment_id: context.payload.comment.id, content: 'eyes', | ||
| }); | ||
|
Comment on lines
+32
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: For GitHub REST API “issue assignees” endpoints (issues.addAssignees and issues.removeAssignees), the docs only spell out these HTTP response status codes for the assignee-add/remove operations: 1) issues.addAssignees (POST /repos/{owner}/{repo}/issues/{issue_number}/assignees) - 201 Created when assignees are added successfully. [1] - 204 No Content when the assignee can be assigned to issue_number. [1] - 404 Not Found when the assignee cannot be assigned to issue_number. [1] 2) issues.removeAssignees (DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees) - 200 OK when the assignees are removed successfully. [2] When a user is not assignable to a repository issue (i.e., cannot be assigned to that specific issue_number), the REST docs describe the response as 404 Not Found. [1] Note: the removeAssignees operation page shown in the search results explicitly lists only 200 OK, and does not mention additional error status codes on that page. [2] Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE=".github/workflows/issue-self-assign.yml"
# Show the referenced region with some surrounding context
nl -ba "$FILE" | sed -n '1,120p' | catRepository: rocketride-org/rocketride-server Length of output: 119 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE=".github/workflows/issue-self-assign.yml"
if [ ! -f "$FILE" ]; then
echo "Missing $FILE"
exit 1
fi
awk 'NR>=1 && NR<=120 { printf "%4d: %s\n", NR, $0 }' "$FILE"Repository: rocketride-org/rocketride-server Length of output: 1912 Handle GitHub assignee REST failures so the workflow still provides deterministic feedback.
🤖 Prompt for AI Agents |
||
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.
Use exact command matching instead of prefix matching.
startsWith('/assign')will also match comments like/assignment, which currently falls into the assign path. Parse the first token and require exact/assignor/unassignbefore mutating assignees.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents