-
Notifications
You must be signed in to change notification settings - Fork 0
Deploy with Firebase
🔗 Link to the Firebase console
You will need to add Firebase scripts to your HTML document.
- Create a new project on the console.
- Unless you really want Google Analytics, untoggle "Enable Google Analytics for this project".
- On the "Get started by adding Firebase to your app", select the "Web" button,
</>. - Name your app and click "Next".
- Copy-paste the "Add Firebase SDK" code into the
/public/index.htmlfile "into the bottom of your<body>tag, but before you use any Firebase services" - Add additional features, if needed; a CDN link will get you setup quickly. There are other options, such as using Node to install them.
- Install firebase-tools globally.
npm install -g firebase-tools - Check firebase was installed.
firebase --version - Login to your Firebase account.
firebase login - You will be redirected to login to your Google account.
- Logout of your Firebase account if needed.
firebase logout - Initiate a Firebase project in your VSCode workspace.
firebase init- Enable options with the
space bar.- Choose to deploy from
public. - Choose to setup hosting, since we didn't do this when creating the app.
- Choose to deploy from
- Finish your selections with
Enter. This will generate new files in your repository.
- Enable options with the
- If you are using emulators for hosting, then you can start the preview with
firebase emulators:start - Alternatively, you can use the
firebase servecommand. - Deploy your app to Firebase.
firebase deploy
During the firebase init session, you will have the option to choose whether you want to auto-deploy on merge to the main branch and/or on pull request. As long as you want your app to visible live from the web, you should do it! Get your feet wet with CI!
This initiation step will setup two workflow documents in a /.github folder, which are in YAML format.
You can specify build steps which run automatically with a GitHub Action; this is a great time to auto-transpile your ES6.
Here is an example of how this document will look. Please take note of the run step: npm run i && npm run build, which first installs node_modules, then runs the build command specified in the package.json file.
If you also need to build LESS or SASS, you can add them to your build command.
jobs:
build_and_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm run i && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_APP_NAME }}"
projectId: app-name
env:
FIREBASE_CLI_PREVIEWS: hostingchannels