Deploy your first website with Firebase. We are going to use Firebase, Travis, Nodejs and GoDaddy like tech tools.
Deploy your first website with Firebase. We are going to use GitHub, Firebase, Travis CI or GitHub Actions, Nodejs and GoDaddy like tech tools.
src
. Inside that floder create a index.html
file and a assets
folder. Within assets
folder, create two folders called js
and css
. There you are going to save the js files and css files.hosting
tab. Follow the steps to set up the hosting.
4.1 Run (using cmd):
npm install -g firebase-tools
.firebase login
. If the command is not being executed run firebase login --interactive
.firebase init
(Run this command from your app’s root directory).hosting
with spacebar.firebase deploy
.index.html
in the public
. Create a basic layout and deploy again.npm init -y
inside your app folder.prepare.js
file in the root folder.ncp
and rimraf
dependencies (search first the utility. npm website or read this article).
4.1 Run npm i ncp
and npm i rimraf
.prepare.js
.const rimraf = require('rimraf'); //remove files
const ncp = require('ncp').ncp; //copy files
const fs = require('fs');
const public_dir = './public';
const file_list = [
{ fileSource: './src/index.html', fileDest: './public/index.html' },
];
//removes public folder
rimraf('./public/', function (rimraf_error) {
if (rimraf_error) { throw rimraf_error; }
// done
//if public folder doesn't exist
if (!fs.existsSync(public_dir)) {
//creates public folder
fs.mkdirSync(public_dir);
}
file_list.forEach((fileElement, index, array) => {
const { fileSource, fileDest } = fileElement;
copy_files(fileSource, fileDest);
});
})
function copy_files(sourcePath, destPath){
ncp(sourcePath, destPath, function (ncp_error) {
if (ncp_error) { throw ncp_error; }
});
}
node prepare.js
to see how it works.package.json
.
7.1 Add into the scripts attribute: "prepare-public": "node prepare.js"
.
7.2 Try it. Run npm run prepare-public
.firebase login:ci
..travis.yml
file in the root folder.language: node_js
node_js:
- "8"
script:
- echo "Deploy!!"
install:
- npm install -g firebase-tools
- npm install
- npm run prepare-public
after_success:
- firebase deploy --project your_project_name --token $FIREBASE_TOKEN
your_project_name
varialble in the command.
secret
variable in your repo settings.action
in your Actions tab with the following structurename: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js $
uses: actions/setup-node@v1
with:
node-version: $
- run: npm ci
- run: npm install -g firebase-tools
- run: npm install
- run: npm run prepare-public
- run: firebase deploy --token $
env:
CI: true
add a custom domain
A
registers pointing to the values.
name
to @