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 e15212a
Show file tree
Hide file tree
Showing 2 changed files with 12 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
17 changes: 10 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ 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
echo "$GITHUB_WORKSPACE"
gcloud auth login --access-token-file="$GITHUB_WORKSPACE" --project="$INPUT_PROJECT_ID"
fi

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

0 comments on commit e15212a

Please sign in to comment.