Skip to content

Commit

Permalink
feat: add output letting users know if a pull request was created or not
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Jahren committed Nov 13, 2023
1 parent 95174a2 commit b31de42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ inputs:
command_args:
description: 'Additional arguments which will be passed to the Crowdin CLI command'
required: false
outputs:
pull_request_created:
description: 'Whether or not a pull request was created during the action run'

runs:
using: docker
Expand Down
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ create_pull_request() {
auth_status=$(curl -sL --write-out '%{http_code}' --output /dev/null -H "${AUTH_HEADER}" -H "${HEADER}" "${PULLS_URL}")
if [[ $auth_status -eq 403 || "$auth_status" -eq 401 ]] ; then
echo "FAILED TO AUTHENTICATE USING 'GITHUB_TOKEN' CHECK TOKEN IS VALID"
echo "pull_request_created=false" >> $GITHUB_OUTPUT
exit 1
fi

Expand All @@ -111,6 +112,7 @@ create_pull_request() {
# check if pull request exist
if echo "$PULL_REQUESTS" | grep -xq "$BRANCH"; then
echo "PULL REQUEST ALREADY EXIST"
echo "pull_request_created=false" >> $GITHUB_OUTPUT
else
echo "CREATE PULL REQUEST"

Expand All @@ -131,6 +133,12 @@ create_pull_request() {
PULL_REQUESTS_NUMBER=$(echo "${PULL_RESPONSE}" | jq '.number')
view_debug_output

if [ -n "$PULL_REQUESTS_URL" ]; then
echo "pull_request_created=true" >> $GITHUB_OUTPUT
else
echo "pull_request_created=false" >> $GITHUB_OUTPUT
fi

if [ "$PULL_REQUESTS_URL" = null ]; then
echo "FAILED TO CREATE PULL REQUEST"
echo "RESPONSE: ${PULL_RESPONSE}"
Expand Down

0 comments on commit b31de42

Please sign in to comment.