diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 00000000..72a151e5 --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,24 @@ +name: Assign auto + +on: + pull_request: + types: opened + +jobs: + assign: + name: Set assignees + runs-on: ubuntu-18.04 + steps: + - name: Set assignees + env: + ASSIGNEES: ${{ github.actor }} + run: | + assignee_count=$(cat ${{ github.event_path }} | jq '.pull_request.assignees | length') + if [[ 0 == $assignee_count ]]; then + assignees=$(echo "\"${ASSIGNEES// /}\"" | jq 'split(",")') + curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -d "{ \"assignees\": $assignees }" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/assignees + fi