From 48412a068eb725e8028419d49689ce2948d9f3b3 Mon Sep 17 00:00:00 2001 From: Tommaso Sciortino Date: Mon, 2 Mar 2026 11:54:26 -0800 Subject: [PATCH] Add /unassign support (#20864) Co-authored-by: Jacob Richman --- .../workflows/gemini-self-assign-issue.yml | 42 ++++++++++++++++++- CONTRIBUTING.md | 11 +++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gemini-self-assign-issue.yml b/.github/workflows/gemini-self-assign-issue.yml index c0c79e5c04..454fc4f41b 100644 --- a/.github/workflows/gemini-self-assign-issue.yml +++ b/.github/workflows/gemini-self-assign-issue.yml @@ -25,7 +25,7 @@ jobs: if: |- github.repository == 'google-gemini/gemini-cli' && github.event_name == 'issue_comment' && - contains(github.event.comment.body, '/assign') + (contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/unassign')) runs-on: 'ubuntu-latest' steps: - name: 'Generate GitHub App Token' @@ -38,6 +38,7 @@ jobs: permission-issues: 'write' - name: 'Assign issue to user' + if: "contains(github.event.comment.body, '/assign')" uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' with: github-token: '${{ steps.generate_token.outputs.token }}' @@ -108,3 +109,42 @@ jobs: issue_number: issueNumber, body: `👋 @${commenter}, you've been assigned to this issue! Thank you for taking the time to contribute. Make sure to check out our [contributing guidelines](https://github.com/google-gemini/gemini-cli/blob/main/CONTRIBUTING.md).` }); + + - name: 'Unassign issue from user' + if: "contains(github.event.comment.body, '/unassign')" + uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' + with: + github-token: '${{ steps.generate_token.outputs.token }}' + script: | + const issueNumber = context.issue.number; + const commenter = context.actor; + const owner = context.repo.owner; + const repo = context.repo.repo; + const commentBody = context.payload.comment.body.trim(); + + if (commentBody !== '/unassign') { + return; + } + + const issue = await github.rest.issues.get({ + owner: owner, + repo: repo, + issue_number: issueNumber, + }); + + const isAssigned = issue.data.assignees.some(assignee => assignee.login === commenter); + + if (isAssigned) { + await github.rest.issues.removeAssignees({ + owner: owner, + repo: repo, + issue_number: issueNumber, + assignees: [commenter] + }); + await github.rest.issues.createComment({ + owner: owner, + repo: repo, + issue_number: issueNumber, + body: `👋 @${commenter}, you have been unassigned from this issue.` + }); + } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 28e3c775d3..d442f408f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,11 +75,14 @@ Replace `` with your pull request number. Authors are encouraged to run this on their own PRs for self-review, and reviewers should use it to augment their manual review process. -### Self assigning issues +### Self-assigning and unassigning issues -To assign an issue to yourself, simply add a comment with the text `/assign`. -The comment must contain only that text and nothing else. This command will -assign the issue to you, provided it is not already assigned. +To assign an issue to yourself, simply add a comment with the text `/assign`. To +unassign yourself from an issue, add a comment with the text `/unassign`. + +The comment must contain only that text and nothing else. These commands will +assign or unassign the issue as requested, provided the conditions are met +(e.g., an issue must be unassigned to be assigned). Please note that you can have a maximum of 3 issues assigned to you at any given time.