Created
May 2, 2019 08:56
-
-
Save evilUrge/cf6da9bf762b7020ea515b3297f3d273 to your computer and use it in GitHub Desktop.
Deploy to firebase with any CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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