Skip to content

Commit db97ece

Browse files
committed
refactor: use SA
1 parent abb5d91 commit db97ece

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/deploy.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
# Executed when the `master` or `staging` branches of PokeAPI/api-data and PokeAPI/pokeapi.co are pushed to
33
# Runs in CircleCI
44
# Deploys both pokeapi.co and api-data to Firebase in the respective project
5-
# $FIREBASE_DEPLOY_TOKEN, $FIREBASE_PROJECT_ID, $FIREBASE_DEPLOY_TOKEN_STAGING, $FIREBASE_PROJECT_ID_STAGING are present in CircleCI
5+
# $GCP_SA, $FIREBASE_PROJECT_ID, $GCP_SA_STAGING, $FIREBASE_PROJECT_ID_STAGING are present in CircleCI
66
# $deploy_location is an environment variable set when the job is triggered by one of the two repositories getting pushed. If not present then the deploy was triggered by a commit on the master or staging branch of this very repository.
77

8-
if [ "${deploy_location:=$CIRCLE_BRANCH}" = 'master' ]; then # bash parameter expansion (assign default value)
8+
GOOGLE_APPLICATION_CREDENTIALS=gcp_sa.json
9+
10+
if [ "${deploy_location:=$CIRCLE_BRANCH}" = 'master' ]; then
911
echo 'Deploying master branches of PokeAPI/api-data and PokeAPI/pokeapi.co to https://pokeapi.co'
10-
TOKEN=${FIREBASE_DEPLOY_TOKEN}
12+
echo "$GCP_SA" > gcp_sa.json
1113
PROJECT=${FIREBASE_PROJECT_ID}
1214
elif [ "${deploy_location}" = 'staging' ]; then
1315
echo 'Deploying staging branches of PokeAPI/api-data and PokeAPI/pokeapi.co to the staging location'
14-
TOKEN=${FIREBASE_DEPLOY_TOKEN_STAGING}
16+
echo "$GCP_SA_STAGING" > gcp_sa.json
1517
PROJECT=${FIREBASE_PROJECT_ID_STAGING}
1618
fi
1719

@@ -35,5 +37,5 @@ tar xzf static_website.tar.gz -C public
3537

3638
# Deploy to Firebase
3739
(cd functions_v1 && npm ci)
38-
# (cd functions_v2 && npm ci) # Not used due to high costs. When v1 will be sunsetting, switch to v2
40+
# (cd functions_v2 && npm ci) # Not used due to high costs. Only when v1 will be removed, switch to v2
3941
functions_v1/node_modules/.bin/firebase deploy --token="$TOKEN" --project="${PROJECT}" --only functions:api_v1functions,hosting

0 commit comments

Comments
 (0)