- Go to https://console.firebase.google.com and create a new project (unless you already have a project and this is just an additional component to it).
npm install -g firebase-tools
- Login to firebase (setup on your local machine) using
firebase loginwhich opens a browser and you can select your account. Use
firebase logoutin case you are already logged in but to the wrong account.
- In the root of your hugo site initialize the Firebase project with
- Choose Hosting in the feature question
- Choose the project you did just setup
- Accept the default for database rules file
- Accept the default for the publish directory which is
- Choose No in the question if it is a single-page app
hugo && firebase deploy and your site will be up in no time.
Alternatively Create a
deploy.sh file with the following content and make it executable
chmod +x deploy.sh:
#!/bin/sh rm -rf public hugo firebase deploy
- Generate a deploy token using
- Setup your CI
- Add the token to a private variable like
This is a private secret and it should not appear in a public repository. Make sure you understand you chosen CI and that it’s not visible to others.
- Add a step in your build to do
firebase deploy --token $FIREBASE_DEPLOY_TOKEN
Map a custom domain to a Firebase project
Configure CI runner
- Get a deploy token for your Firebase project executing
firebase login:ciwhich will bring up a browser with the authentication dialog and afterwards gives you a token to be used in CI
- In your GitLab project, go to Pipelines > Environments and then add a new environment called Production