Skip to content

Commit

Permalink
Merge pull request #8 from rciovati/rc/fix-script
Browse files Browse the repository at this point in the history
Fix unbound variable error
  • Loading branch information
abinoda authored Sep 20, 2019
2 parents c602aea + 5730be3 commit d8e8959
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
set -e

if [[ -z "$GITHUB_TOKEN" ]]; then
echo "Set the GITHUB_TOKEN env variable."
Expand All @@ -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}"
Expand Down Expand Up @@ -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}" \
Expand Down

0 comments on commit d8e8959

Please sign in to comment.