-
Notifications
You must be signed in to change notification settings - Fork 19
31 lines (28 loc) · 1.44 KB
/
assign_or_assign.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
name: Assign-or-Unassign-Issue
# Ref: https://docs.github.com/en/rest/issues/assignees#about-the-issue-assignees-api
# Ref: https://docs.github.com/en/actions/using-workflows/about-workflows
# Ref permissions: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
on:
issue_comment:
types: created
permissions:
issues: write
jobs:
issue_assign_job:
runs-on: ubuntu-latest
steps:
# This job only runs for issue comments.
- if: github.event.comment.body == 'take' && !github.event.issue.pull_request
run: |
echo "Assigning issue ${{ github.event.issue.number }} to ${{ github.event.comment.user.login }}"
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
# This job only runs for issue comments.
- if: github.event.comment.body == 'remove' && !github.event.issue.pull_request
run: |
echo "Unassigning issue ${{ github.event.issue.number }} from ${{ github.event.comment.user.login }}"
curl \
-X DELETE \
-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