Skip to content

Instantly share code, notes, and snippets.

@ohmrefresh
Forked from rambabusaravanan/README.md
Created September 16, 2018 06:32
Show Gist options
  • Save ohmrefresh/8c294d0e71030bf9fea6d5ed0c471ccf to your computer and use it in GitHub Desktop.
Save ohmrefresh/8c294d0e71030bf9fea6d5ed0c471ccf to your computer and use it in GitHub Desktop.
GitLab CI Configuration YAML

Firebase Deployment

Step 1: Get Token

Generate the firebase token from your terminal using the command $ firebase login:ci

Waiting for authentication...

✔ Success! Use this token to login on a CI server:

1/VXXXXXXX--YOUR-FIREBASE-CI-TOKEN--XXXXXh92o

Example: firebase deploy --token "$FIREBASE_TOKEN"

Step 2: Setup Variable

GitLab Repo -> Settings -> CI/CD -> Secret Variables -> Add the below

Key: FIREBASE_TOKEN

Value: 1/VXXXXXXX--YOUR-FIREBASE-CI-TOKEN--XXXXXh92o

Note:

  • Replace the <project-name> with your firebase project name
  • Entire cache: block and yarn, yarn run build scripts (Line no: 6-9, 16-17) are not needed for non node projects like simple webpages having no package.json

Heroku Deployment

Step 1: Get Token

Go to Account Settings from your account and Reveal the API Key

-or-

Get the heroku auth token from your terminal using the command $ heroku auth:token

79xxYOUR-HERO-KUxx-AUTH-TOKENxxxxx62

Step 2: Setup Variable

GitLab Repo -> Settings -> CI/CD -> Secret Variables -> Add the below

Key: HEROKU_TOKEN

Value: 79xxYOUR-HERO-KUxx-AUTH-TOKENxxxxx62

Note: Heroku deployment will occur only if pushed to heroku's master branch (Line no: 10).

  • For master branch deployments, git push heroku master can be used as usual
  • For non-master branch deployments, the current branch / HEAD is pushed with different remote-tracking branch name as 'master' git push heroku HEAD:master
  • The flag -f force push is needed if 'force push' is allowed in your code repository
image: rambabusaravanan/firebase
stages:
- deploy
cache: # no need if not node project
paths: # no need if not node project
- node_modules/ # no need if not node project
key: "$CI_REPOSITORY_URL" # no need if not node project
deploy-prod:
stage: deploy
only:
- master
script:
- yarn # no need if not node project
- yarn run build # no need if not node project
- firebase use <project-name> --token $FIREBASE_TOKEN
- firebase deploy --only hosting -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID @ Hash ${CI_COMMIT_SHA:0:7}" --token $FIREBASE_TOKEN
stages:
- deploy
deploy-heroku:
stage: deploy
only:
- dev
script:
- git remote add heroku https://heroku:[email protected]/ontro-api.git
- git push heroku HEAD:master -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment