diff --git a/action.yml b/action.yml index 8a44005..f8a6f15 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,8 @@ inputs: required: true service_account_key: description: 'Base64 encoded JSON key for GCP service account' - required: true + required: false + default: '' image_name: description: 'Name of container image to be deployed' required: true diff --git a/entrypoint.sh b/entrypoint.sh index 5d9aea5..70ccb77 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,13 +21,13 @@ SERVICE_NAME_LENGTH_LIMIT=62 set -e set -o pipefail - -echo "$INPUT_SERVICE_ACCOUNT_KEY" | base64 -d >key.json -trap "{ rm -f key.json; }" EXIT - -enableDebug -gcloud auth activate-service-account --key-file=key.json --project="$INPUT_PROJECT_ID" -disableDebug +if [ -n "$INPUT_SERVICE_ACCOUNT_KEY" ]; then + echo "$INPUT_SERVICE_ACCOUNT_KEY" | base64 -d >key.json + trap "{ rm -f key.json; }" EXIT + enableDebug + gcloud auth activate-service-account --key-file=key.json --project="$INPUT_PROJECT_ID" + disableDebug +fi IMAGE_TAG="latest" if [ -n "$INPUT_IMAGE_TAG" ]; then diff --git a/tests/run.bats b/tests/run.bats index 9d3a534..8ceacd8 100755 --- a/tests/run.bats +++ b/tests/run.bats @@ -50,9 +50,7 @@ function debug() { -i $IMAGE debug "${status}" "${output}" "${lines}" - - echo $output | grep -q "Could not read json file key.json" - [[ "${status}" -eq 1 ]] + [[ "${status}" -eq 0 ]] } @test "start hadolint" {