Skip to content

Instantly share code, notes, and snippets.

@dinukasal
Last active June 2, 2019 06:45
Show Gist options
  • Save dinukasal/54ad8607a308c46e9e83204389f07e49 to your computer and use it in GitHub Desktop.
Save dinukasal/54ad8607a308c46e9e83204389f07e49 to your computer and use it in GitHub Desktop.
gitlab ci for building and pushing react app to google cloud(gcloud) storage
image: nikolaik/python-nodejs:latest
before_script:
# Install CA certs, openssl to https downloads, python for gcloud sdk
- apt install -y 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
- google-cloud-sdk/bin/gcloud --quiet components update
- google-cloud-sdk/bin/gcloud auth activate-service-account --key-file $GCLOUD_SERVICE_KEY
- google-cloud-sdk/bin/gcloud config set project lift-srilanka
- npm i -g yarn
- yarn
stages:
- publish
cache:
paths:
- node_modules/
publish:
stage: publish
script:
- CI=false yarn build
- google-cloud-sdk/bin/gcloud app deploy
only:
- tags
@dinukasal
Copy link
Author

seems this is better,

image: google/cloud-sdk:alpine

deploy_production:
  stage: deploy
  environment: Production
  only:
  - master
  script:
  - echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
  - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
  - gcloud --quiet --project $PROJECT_ID app deploy app.yaml dispatch.yaml

deploy_staging:
  stage: deploy
  environment: Staging
  only:
  - staging
  script:
  - echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
  - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
  - gcloud --quiet --project $PROJECT_ID app deploy staging-app.yaml

after_script:
- rm /tmp/$CI_PIPELINE_ID.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment