Skip to content

Commit

Permalink
feat: introduce service account keyless authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
kharf committed Apr 11, 2024
1 parent 40a6695 commit 443c59a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ 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
else
gcloud auth login --cred-file="$GOOGLE_GHA_CREDS_PATH"
fi

IMAGE_TAG="latest"
if [ -n "$INPUT_IMAGE_TAG" ]; then
Expand Down

0 comments on commit 443c59a

Please sign in to comment.