Skip to content

Commit 896accc

Browse files
authored
feat: add github action to self-assign the issue (#337)
Closes #324. --------- Signed-off-by: tailm <Tai Le Manh> Signed-off-by: Tai Le Manh <[email protected]> Co-authored-by: tailm <Tai Le Manh>
1 parent b3a3b7d commit 896accc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Auto assign the issue via `take` comment
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
auto-assign:
12+
runs-on: ubuntu-latest
13+
if: (!github.event.issue.pull_request) && github.event.comment.body == 'take'
14+
concurrency:
15+
# Only run one at a time for each user.
16+
group: ${{ github.actor }}-issue-assign
17+
steps:
18+
- run: |
19+
CODE=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -LI https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees/${{ github.event.comment.user.login }} -o /dev/null -w '%{http_code}\n' -s)
20+
if [ "$CODE" -eq "204" ]
21+
then
22+
echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
23+
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
24+
else
25+
echo "Cannot assign issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
26+
fi

0 commit comments

Comments
 (0)