FIREBASE HOSTING DEPLOYMENT AUTOMATION WITH GITLAB CI

SalmaN SulthaN
Nov 3 · 3 min read
  • Open browser, go to Gitlab https://gitlab.com
  • Log in to your account
  • Create a new project or open an existing one
  • Open Terminal, choose your desired directory

Type git clone <repository URL> and hit return / enter

  • Open VS Code -> Open folder -> Select Project Folder and click open
  • Create .gitlab-ci.yml file
  • Copy the below code and paste it in the .yml file:
image: node:alpinedeploy_production:
stage: deploy
environment: Production
only:
- master
script:
- npm install
- npm i -g firebase-tools
- firebase deploy --non-interactive --token "<token>" --project <project ID>
  • Create firebase.json file and copy paste the below code in it
{   
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
  • Open browser, go to Firebase Console
  • Create a new project or open an existing one
  • Click Project Settings
  • Open terminal
  • Type npm install and hit return / enter
  • Type npm i -g firebase-tools and hit return / enter
  • Type firebase login and hit return / enter
  • Type y and hit return / enter
  • Your default web browser will be opened, choose your Google account, the one which you created your Firebase project and click Allow.
  • You should see the below success message:
  • Type firebase login:ci and hit return / enter. Your default web browser will be opened, choose your Google account, the one which you created your Firebase project and click Allow.
  • Go back to Terminal and you should see a token like below:
  • Copy the token and replace it with <token> in the .yml file.
  • Copy your project ID from Firebase Console and replace it with <project ID>

Save your .yml file

Commit your changes and push it to the repository

Create all your web files (index.html , …) inside the public folder. Save, commit and push the code.

Happy coding and DevOps

By Salman

SalmaN SulthaN

Written by

I am a Project Coordinator. I am here to write contents / tutorials which can benefit people.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade