Skip to content

Commit

Permalink
Merge pull request #226 from paulooctavio/feature/auto-assign-issue-a…
Browse files Browse the repository at this point in the history
…ction

Added GitHub action to auto-assign issues
  • Loading branch information
SemyonSinchenko authored Jun 13, 2024
2 parents 1e41943 + 19c702d commit c820388
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/assign-on-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow was inspired by the issue_comments.yml workflow from the delta-io/delta-rs repository.
# Source: https://github.com/delta-io/delta-rs/blob/main/.github/workflows/issue_comments.yml
name: Auto-assign issue on comment

on:
issue_comment:
types: [created]

permissions:
issues: write

jobs:
auto-assign-issue:
runs-on: ubuntu-latest
if: (!github.event.issue.pull_request) && github.event.comment.body == 'take'
concurrency:
# Only run one a time per user
group: ${{ github.actor }}-auto-assign-issue
steps:
- name: Check if issue can be assigned
id: check-assignee
run: |
RESPONSE=$(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}' -s)
echo "HTTP_CODE=$RESPONSE" >> $GITHUB_ENV
- name: Assign issue to commenter
if: env.HTTP_CODE == '204'
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Log failure to assign
if: env.HTTP_CODE != '204'
run: |
echo "Issue #${{ github.event.issue.number }} cannot be assigned to @${{ github.event.comment.user.login }}. HTTP response code: ${{ env.HTTP_CODE }}"

0 comments on commit c820388

Please sign in to comment.