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
This commit is contained in:
Srdjan Grubor
2020-03-17 11:02:28 -05:00
parent a3ee64d51c
commit a3c90d58a7

View File

@@ -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