diff --git a/bin/add-reviewer.sh b/bin/add-reviewer.sh index 6d9ea62..459be08 100755 --- a/bin/add-reviewer.sh +++ b/bin/add-reviewer.sh @@ -3,11 +3,24 @@ IFS="," login="${*}" +login="${login//\@/}" if [[ -z "${login}" ]]; then echo "[FAIL] No login provided" exit 1 fi -echo "Add reviewer ${login//\@/} to ${GH_REPOSITORY}#${ISSUE_NUMBER}" -gh "${ISSUE_KIND}" -R "${GH_REPOSITORY}" edit "${ISSUE_NUMBER}" --add-reviewer "${login//\@/}" +echo "Add reviewer ${login} to ${GH_REPOSITORY}#${ISSUE_NUMBER}" + +# gh pr edit --add-reviewer Don't acquire organizational teams if it's not necessary +# see more https://github.com/wzshiming/gh-ci-bot/issues/1 +# gh "${ISSUE_KIND}" -R "${GH_REPOSITORY}" edit "${ISSUE_NUMBER}" --add-reviewer "${login}" + +for reviewer in ${login}; do + curl \ + -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${GH_TOKEN}" \ + "https://api.github.com/repos/${GH_REPOSITORY}/pulls/${ISSUE_NUMBER}/requested_reviewers" \ + -d "{\"reviewers\":[\"${reviewer}\"],\"team_reviewers\":[]}" +done diff --git a/bin/remove-reviewer.sh b/bin/remove-reviewer.sh index 5930ff9..508f2dc 100755 --- a/bin/remove-reviewer.sh +++ b/bin/remove-reviewer.sh @@ -3,6 +3,7 @@ IFS="," login="${*}" +login="${login//\@/}" if [[ -z "${login}" ]]; then echo "[FAIL] No login provided" @@ -10,4 +11,16 @@ if [[ -z "${login}" ]]; then fi echo "Remove reviewer ${login//\@/} to ${GH_REPOSITORY}#${ISSUE_NUMBER}" -gh "${ISSUE_KIND}" -R "${GH_REPOSITORY}" edit "${ISSUE_NUMBER}" --remove-reviewer "${login//\@/}" + +# gh pr edit --add-reviewer Don't acquire organizational teams if it's not necessary +# see more https://github.com/wzshiming/gh-ci-bot/issues/1 +# gh "${ISSUE_KIND}" -R "${GH_REPOSITORY}" edit "${ISSUE_NUMBER}" --remove-reviewer "${login}" + +for reviewer in ${login}; do + curl \ + -X DELETE \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${GH_TOKEN}" \ + "https://api.github.com/repos/${GH_REPOSITORY}/pulls/${ISSUE_NUMBER}/requested_reviewers" \ + -d "{\"reviewers\":[\"${reviewer}\"],\"team_reviewers\":[]}" +done