Skip to content

Commit

Permalink
Add reviewer(s) when creating a pull-request
Browse files Browse the repository at this point in the history
  • Loading branch information
ultr4nerd committed Oct 28, 2022
1 parent 69106f5 commit e911f18
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ In case you don’t want to download translations from Crowdin (`download_transl
pull_request_body: 'New Crowdin pull request with translations'
pull_request_labels: 'enhancement, good first issue'
pull_request_assignees: 'crowdin-bot'
pull_request_reviewers: 'crowdin-reviewer'
# This is the name of the git branch to with pull request will be created.
# If not specified default repository branch will be used.
pull_request_base_branch_name: not_default_branch
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ inputs:
pull_request_assignees:
description: 'Add up to 10 assignees to the created pull request (separated by comma)'
required: false
pull_request_reviewers:
description: 'Usernames of people from whom a review is requested for this pull request (separated by comma)'
required: false
pull_request_labels:
description: 'To add labels for created pull request'
required: false
Expand Down
15 changes: 15 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ create_pull_request() {
fi
fi

if [ -n "$INPUT_PULL_REQUEST_REVIEWERS" ]; then
PULL_REQUEST_REVIEWERS=$(echo "[\"${INPUT_PULL_REQUEST_REVIEWERS}\"]" | sed 's/, \|,/","/g')

if [ "$(echo "$PULL_REQUEST_REVIEWERS" | jq -e . > /dev/null 2>&1; echo $?)" -eq 0 ]; then
echo "ADD REVIEWERS TO PULL REQUEST"

REVIEWERS_URL="${REPO_URL}/pulls/${PULL_REQUESTS_NUMBER}/requested_reviewers"
REVIEWERS_DATA="{\"reviewers\":${PULL_REQUEST_REVIEWERS}}"

curl -sSL -H "${AUTH_HEADER}" -H "${HEADER}" -X POST --data "${REVIEWERS_DATA}" "${REVIEWERS_URL}"
else
echo "JSON OF pull_request_reviewers IS INVALID: ${PULL_REQUEST_REVIEWERS}"
fi
fi

echo "PULL REQUEST CREATED: ${PULL_REQUESTS_URL}"
fi
}
Expand Down

0 comments on commit e911f18

Please sign in to comment.