Skip to content

Instantly share code, notes, and snippets.

@evilUrge
Created May 2, 2019 08:56
Show Gist options
  • Save evilUrge/cf6da9bf762b7020ea515b3297f3d273 to your computer and use it in GitHub Desktop.
Save evilUrge/cf6da9bf762b7020ea515b3297f3d273 to your computer and use it in GitHub Desktop.
Deploy to firebase with any CI
const fs = require('fs');
const token = process.env['FIREBASE_TOKEN']; // Keep your firebase cli token in FIREBASE_TOKEN as a env param
const projectName = (JSON.parse(fs.readFileSync(`${__dirname}/.firebaserc`, 'utf8')))
.projects[process.env.NODE_ENV ? process.env.NODE_ENV : 'default'];
/**
* FireBase Deployment script
* FOR CI USE ONLY!
*/
console.log('Deploying to Firebase... please wait.');
token ? require('firebase-tools')
.deploy((() => ({project: projectName, token: token, cwd: __dirname}))())
.then(() => console.log(`Your project ${projectName} has been deployed`))
.catch((err) => console.warn(`error has occurred! - ${err}`))
: console.error('waitt...where is your firebase token?');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment