From 82d8bbdc763db9c76a8351bf4ee4ed5552ce62ee Mon Sep 17 00:00:00 2001 From: laminar Date: Wed, 12 Jul 2023 13:46:28 +0800 Subject: [PATCH] add auto_assign and assign bot Signed-off-by: laminar --- .github/auto_assign.yml | 23 +++++++++++++++++++++++ .github/workflows/assign.yml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/auto_assign.yml create mode 100644 .github/workflows/assign.yml diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml new file mode 100644 index 00000000..8475e921 --- /dev/null +++ b/.github/auto_assign.yml @@ -0,0 +1,23 @@ +# Set to true to add reviewers to pull requests +addReviewers: true + +# Set to author to set pr creator as assignee +addAssignees: author + +# A list of reviewers to be added to pull requests (GitHub user name) +reviewers: + - benjaminhuo + - kehuili + - tpiperatgod + +# A list of keywords to be skipped the process that add reviewers if pull requests include it +skipKeywords: + - wip + +# A number of reviewers added to the pull request +# Set 0 to add all the reviewers (default: 0) +numberOfReviewers: 1 + +# A list of users to be skipped by both the add reviewers and add assignees processes +skipUsers: + - dependabot[bot] diff --git a/.github/workflows/assign.yml b/.github/workflows/assign.yml new file mode 100644 index 00000000..4e878b5d --- /dev/null +++ b/.github/workflows/assign.yml @@ -0,0 +1,32 @@ +name: Assign issue + +on: + issue_comment: + types: [created] + +jobs: + assignbot: + runs-on: ubuntu-latest + steps: + - name: Assign issue + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const payload = context.payload; + const issue = context.issue; + const isFromPulls = !!payload.issue.pull_request; + const commentBody = payload.comment.body; + + if (!isFromPulls && commentBody && commentBody.indexOf("/assign") == 0) { + if (!issue.assignees || issue.assignees.length === 0) { + await github.rest.issues.addAssignees({ + owner: issue.owner, + repo: issue.repo, + issue_number: issue.number, + assignees: [context.actor], + }) + } + + return; + }