Skip to content

Commit

Permalink
🏗 Use new key for storage (#32939)
Browse files Browse the repository at this point in the history
* new key

* src change

* undo src change

* remove config set

* use latest sdk
  • Loading branch information
estherkim committed Feb 26, 2021
1 parent b2291b5 commit 34acc5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions .circleci/setup_storage.sh
Expand Up @@ -22,28 +22,24 @@ set -e
GREEN() { echo -e "\033[0;32m$1\033[0m"; }
RED() { echo -e "\033[0;31m$1\033[0m"; }

if [[ -z "${GCP_TOKEN}" ]] ;
if [[ -z "${STORAGE_TOKEN}" ]] ;
then
echo $(RED "Could not find the GCP_TOKEN environment variable. Exiting.")
echo $(RED "Could not find the STORAGE_TOKEN environment variable. Exiting.")
exit 1
fi

echo $(GREEN "Installing Google Cloud SDK...")
(set -x && cd ~/ && curl -Ss --retry 5 https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-323.0.0-linux-x86_64.tar.gz | tar xz)
(set -x && cd ~/ && curl -Ss --retry 5 https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-329.0.0-linux-x86_64.tar.gz | tar xz)

echo $(GREEN "Setting up Cloud SDK environment...")
(set -x && echo "source ~/google-cloud-sdk/path.bash.inc" >> $BASH_ENV)
source $BASH_ENV

echo $(GREEN "Extracting credentials...")
openssl aes-256-cbc -k $GCP_TOKEN -in ./build-system/common/sa-travis-key.json.enc -out sa-travis-key.json -d

echo $(GREEN "Authenticating with GCP storage...")
gcloud auth activate-service-account --key-file=sa-travis-key.json
echo $STORAGE_TOKEN > storage-key.json
gcloud auth activate-service-account --key-file=storage-key.json

echo $(GREEN "Applying settings...")
gcloud config set account sa-travis@amp-travis-build-storage.iam.gserviceaccount.com
gcloud config set pass_credentials_to_gsutil true
gcloud config set project amp-travis-build-storage

echo $(GREEN "Successfully set up GCP storage.")
Binary file removed build-system/common/sa-travis-key.json.enc
Binary file not shown.

0 comments on commit 34acc5e

Please sign in to comment.