Skip to content

Commit 275774b

Browse files
committed
feat(CI): add /assign command for issue self-assignment
Signed-off-by: Rahul-R79 <rahul.devworks@gmail.com>
1 parent 6c2442f commit 275774b

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ assignees: ''
4141

4242
## Possible Implementation
4343
<!--- Not obligatory, but suggest an idea for implementing addition or change -->
44+
45+
_Tip: You can self-assign this issue by commenting `/assign` if you are working on it._

.github/ISSUE_TEMPLATE/custom-issue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ assignees: ''
1616

1717
## Detailed Description
1818
<!--- Provide any further details -->
19+
20+
_Tip: You can self-assign this issue by commenting `/assign` if you are working on it._

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ assignees: ''
2323

2424
## Detailed Description
2525
<!--- Provide a detailed description of the change or addition you are proposing -->
26+
27+
_Tip: You can self-assign this issue by commenting `/assign` if you are working on it._
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Issue Assignment
2+
on:
3+
issue_comment:
4+
types: [created]
5+
6+
permissions:
7+
issues: write
8+
9+
jobs:
10+
assign:
11+
if: |
12+
(!github.event.issue.pull_request) &&
13+
(contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/unassign'))
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Assign or Unassign
17+
uses: actions/github-script@v6
18+
with:
19+
script: |
20+
const comment = context.payload.comment.body.trim();
21+
const user = context.payload.comment.user.login;
22+
const issueNumber = context.payload.issue.number;
23+
24+
if (comment === '/assign') {
25+
console.log(`Assigning issue #${issueNumber} to ${user}`);
26+
await github.rest.issues.addAssignees({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
issue_number: issueNumber,
30+
assignees: [user]
31+
});
32+
} else if (comment === '/unassign') {
33+
console.log(`Unassigning issue #${issueNumber} from ${user}`);
34+
await github.rest.issues.removeAssignees({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
issue_number: issueNumber,
38+
assignees: [user]
39+
});
40+
}

0 commit comments

Comments
 (0)