Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying to Firebase Hosting using CircleCI

Tags:

I'm trying to figure out how to deploy to Firebase Hosting using CircleCI. As far as I know, there is no way to setup deployment with an SSH key, so I'm trying to find a way of logging into Firebase during deployment and push the code. What I have tried so far is the following in my circle.yml:

// circle.yml
deployment:
  production:
    branch: circle-deploy
    commands:
      - npm install -g firebase-tools
      - firebase login | echo -e "${FIREBASE_EMAIL}\n${FIREBASE_PASSWORD}"
      - firebase deploy

However, I keep getting the following error and I'm not sure how to remedy it.

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: write EPIPE
    at errnoException (net.js:904:11)
at Object.afterWrite (net.js:720:19)
like image 210
erichrusch Avatar asked Feb 17 '15 19:02

erichrusch


People also ask

Can CircleCI deploy?

CircleCI can deploy to virtually any target, and can be easily configured to integrate with other services for QA/testing, feature management, and deployment strategies such as blue-green or canary deployment.

Can I host a server on Firebase?

More videos on YouTubeFirebase Hosting is production-grade web content hosting for developers. With a single command, you can quickly deploy web apps and serve both static and dynamic content to a global CDN (content delivery network).


2 Answers

A small addition to the other answers above...

In order to avoid installing firebase-tools globally in circle ci on every build:

Modify your package.json file to include firebase-tools as a dev dependency like so:

npm install --save-dev firebase-tools

Then in your circle.yml file:

deployment:
  production:
    branch: master
    commands:
      - ./node_modules/.bin/firebase deploy --token=$FIREBASE_TOKEN --non-interactive
like image 33
Ilan Klinghofer Avatar answered Oct 18 '22 06:10

Ilan Klinghofer


I just had to do this and there is a easier way

  1. On your machine, you can get your access token by typing

    firebase login:ci
    
  2. Save that token as an environment variable in circleci, $FIREBASE_TOKEN
  3. For your deploy step, you can skip the login:

    deployment:
      production:
        branch: master
        commands:
          - firebase deploy --token=$FIREBASE_TOKEN --non-interactive
    
like image 106
mattmcmanus Avatar answered Oct 18 '22 06:10

mattmcmanus