diff --git a/entrypoint.sh b/entrypoint.sh index 3907882..c0d7729 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -eu +set -e if [[ -z "$GITHUB_TOKEN" ]]; then echo "Set the GITHUB_TOKEN env variable." @@ -16,6 +16,17 @@ if [[ -z "$GITHUB_EVENT_PATH" ]]; then exit 1 fi +addLabel=$ADD_LABEL +if [[ -n "$LABEL_NAME" ]]; then + echo "Warning: Plase define the ADD_LABEL variable instead of the deprecated LABEL_NAME." + addLabel=$LABEL_NAME +fi + +if [[ -z "$addLabel" ]]; then + echo "Set the ADD_LABEL or the LABEL_NAME env variable." + exit 1 +fi + URI="https://api.github.com" API_HEADER="Accept: application/vnd.github.v3+json" AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" @@ -44,12 +55,6 @@ label_when_approved() { if [[ "$approvals" == "$APPROVALS" ]]; then echo "Labeling pull request" - addLabel=$ADD_LABEL - if [[ -n "$LABEL_NAME" ]]; then - echo "Plase define the ADD_LABEL variable instead of the deprecated LABEL_NAME." - addLabel=$LABEL_NAME - fi - curl -sSL \ -H "${AUTH_HEADER}" \ -H "${API_HEADER}" \