Skip to content

Commit

Permalink
Merge pull request #138 from MrChrisW/expand-pull-request-options
Browse files Browse the repository at this point in the history
Assign users to PR via pull_request_assignees
  • Loading branch information
andrii-bodnar authored Oct 10, 2022
2 parents bfdb7f7 + db271b7 commit d985c2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ In case you don’t want to download translations from Crowdin (`download_transl
pull_request_title: 'New Crowdin translations'
pull_request_body: 'New Crowdin pull request with translations'
pull_request_labels: 'enhancement, good first issue'
pull_request_assignees: 'crowdin-bot'
# 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 @@ -81,6 +81,9 @@ inputs:
pull_request_body:
description: 'The contents of the pull request'
required: false
pull_request_assignees:
description: 'Add up to 10 assignees to the created pull request (separated by comma)'
required: false
pull_request_labels:
description: 'To add labels for created pull request'
required: false
Expand Down
17 changes: 17 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ create_pull_request() {
fi
fi

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

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

ASSIGNEES_URL="${REPO_URL}/issues/${PULL_REQUESTS_NUMBER}/assignees"

ASSIGNEES_DATA="{\"assignees\":${PULL_REQUEST_ASSIGNEES}}"

# add assignees to created pull request
curl -sSL -H "${AUTH_HEADER}" -H "${HEADER}" -X POST --data "${ASSIGNEES_DATA}" "${ASSIGNEES_URL}"
else
echo "JSON OF pull_request_assignees IS INVALID: ${PULL_REQUEST_ASSIGNEES}"
fi
fi

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

0 comments on commit d985c2d

Please sign in to comment.