-
-
Save Albinzr/77bac3bc9ba0ccf7f4d92c4ec5192ff7 to your computer and use it in GitHub Desktop.
Deploy Google Cloud Functions: GitLab CI/CD Pipeline Config File
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
variables: | |
GCP_PROJECT_ID: {YOUR GOOGLE CLOUD PROJECT ID} | |
GCP_ZONE: us-central1-a | |
services: | |
- docker:dind | |
stages: | |
- npm-install | |
- push | |
npm-install: | |
image: node:8-alpine | |
stage: npm-install | |
only: | |
- master | |
script: | |
- cd gcsSignedUrl | |
- npm install | |
artifacts: | |
paths: | |
- gcsSignedUrl/node_modules/ | |
push: | |
stage: push | |
image: docker:latest | |
only: | |
- master | |
dependencies: | |
- npm-install | |
script: | |
# Install CA certs, openssl to https downloads, python for gcloud sdk | |
- apk add --update make ca-certificates openssl python | |
- update-ca-certificates | |
# Download and install Google Cloud SDK | |
- wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz | |
- tar zxvf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true | |
- PATH="google-cloud-sdk/bin:${PATH}" | |
- gcloud --quiet components update | |
- gcloud components install beta | |
# Authenticate using the service account stored here: https://gitlab.com/groups/{YOUR_GITLAB_PROJECT}/-/settings/ci_cd | |
- echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json | |
- gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json | |
- gcloud config set project $GCP_PROJECT_ID | |
# Deploy | |
- gcloud beta functions deploy gcsSignedUrl --source=./gcsSignedUrl --trigger-http |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment