Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A GitHub Action for creating pull requests.
* Create pull requests
* Add reviewers, assignees, labels, or milestones
* Customize pull request title and body
* Fail silently when a pull request already exists
* Retrieve the existing pull request URL in case pull request already exists


## Usage
Expand Down
21 changes: 19 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,33 @@ if [[ "$INPUT_PR_DRAFT" == "true" ]]; then
fi

COMMAND="GITHUB_TOKEN=\"$GITHUB_TOKEN\" hub pull-request \
-b $DESTINATION_BRANCH \
-h $SOURCE_BRANCH \
-b $DESTINATION_BRANCH \
--no-edit \
$PR_ARG \
|| true"

echo "$COMMAND"

PR_URL=$(sh -c "$COMMAND")
if [[ "$?" != "0" ]]; then


if [[ -z "$PR_URL" ]]; then
# in case PR already exists, get its url
COMMAND="GITHUB_TOKEN=\"$GITHUB_TOKEN\" hub pr list \
-h $SOURCE_BRANCH \
-b $DESTINATION_BRANCH \
-f \"%U\" \
| head -n 1 \
|| true"

echo "$COMMAND"

PR_URL=$(sh -c "$COMMAND")
fi

if [[ -z "$PR_URL" ]]; then
echo "Failed to create or retrieve existing pull request."
exit 1
fi

Expand Down