Skip to content

Instantly share code, notes, and snippets.

@bhubbard
Forked from mderazon/.travis.yml
Created April 26, 2018 05:29
Show Gist options
  • Save bhubbard/348a048c7a46f0a292a6569f2596cb24 to your computer and use it in GitHub Desktop.
Save bhubbard/348a048c7a46f0a292a6569f2596cb24 to your computer and use it in GitHub Desktop.
Automatic deployment to Google Cloud Functions with Travis-ci
# Use Dockerized infrastructure
sudo: false
# Use node_js environnement
language: node_js
node_js:
- "6"
# Cache Gcloud SDK between commands
cache:
yarn: true
directories:
- "$HOME/google-cloud-sdk/"
env:
global:
install:
- npm install
script:
- npm test
before_deploy:
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
- source /home/travis/google-cloud-sdk/path.bash.inc
- gcloud --quiet version
- gcloud --quiet components update
# use the decrypted service account credentials to authenticate the command line tool
# get the encrypted variable names from travis cli: https://docs.travis-ci.com/user/encrypting-files/
- openssl aes-256-cbc -K $TRAVIS_ENCRYPTED_key -iv $TRAVIS_ENCRYPTED_iv -in gcloud-service-key.json.enc -out gcloud-service-key.json -d
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- gcloud config set project PROJECT
deploy:
- provider: script
script:
# change PROJECT and REPO to the values from the cloud console: https://console.cloud.google.com/code/develop
- gcloud --quiet beta functions deploy mailer --source-url https://source.developers.google.com/p/PROJECT/r/REPO --source-path / --trigger-http
skip_cleanup: true
on:
branch: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment