From a3c90d58a799af3801ace9708b790ced22b7507c Mon Sep 17 00:00:00 2001 From: Srdjan Grubor Date: Tue, 17 Mar 2020 11:02:28 -0500 Subject: [PATCH] Fix action branch logic for pull requests Without this change, `BRANCH` will be `null` for triggers that don't have an associated branch like `release: [published]`. Closes #20 --- pull-request.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pull-request.sh b/pull-request.sh index 4a55f93..9562464 100755 --- a/pull-request.sh +++ b/pull-request.sh @@ -109,7 +109,13 @@ main () { # Get the name of the action that was triggered BRANCH=$(jq --raw-output .ref "${GITHUB_EVENT_PATH}"); BRANCH=$(echo "${BRANCH/refs\/heads\//}") - echo "Found branch $BRANCH" + + if [[ "$BRANCH" != "null" ]]; then + echo "Found branch $BRANCH" + else + echo "No trigger branch found in event data. Using '$BRANCH_PREFIX' as BRANCH instead." + BRANCH="$BRANCH_PREFIX" + fi # If it's to the target branch, ignore it if [[ "${BRANCH}" == "${PULL_REQUEST_BRANCH}" ]]; then