Last active
April 13, 2020 11:05
-
-
Save mderazon/5a5b50d92f4c4adaf44d5f49dd95d0ef to your computer and use it in GitHub Desktop.
Automatic deployment to Google Cloud Functions with Travis-ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
could read
where
FUNCTION_NAME
is the main function found in index.js in the formatexports.FUNCTION_NAME = (request, response) => {
please see and feel free to copy my fork, as unfortunately, gist does not support pull requests