Skip to content

Instantly share code, notes, and snippets.

@gotwalt
Last active August 4, 2017 16:14
Show Gist options
  • Save gotwalt/e42f4c1c6e7e84c05fa6be6a1b9d854d to your computer and use it in GitHub Desktop.
Save gotwalt/e42f4c1c6e7e84c05fa6be6a1b9d854d to your computer and use it in GitHub Desktop.
Circle CI 2.0 building a node app and continuously deploying to Google App Engine
version: 2
jobs:
build:
docker:
- image: circleci/node:8.1
working_directory: ~/web
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# run tests!
- run: npm run test
deploy:
docker:
- image: google/cloud-sdk
working_directory: ~/web
steps:
- checkout
- deploy:
name: "Deploy to App Engine"
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
./.circleci/deploy.sh
fi
workflows:
version: 2
build_and_deploy:
jobs:
- build
- deploy:
requires:
- build
#!/usr/bin/env bash
echo $GCLOUD_SERVICE_KEY | base64 --decode --ignore-garbage > ${HOME}/gcloud-service-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
gcloud app deploy --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment