Firebase Deployment
This page documents deployments using dpl v1 which is currently the legacy version. The dpl v2 is released, and we recommend useig it. Please see our blog post for details. dpl v2 documentation can be found here.
Travis CI can automatically deploy your application to Firebase after a successful build.
To use the default configuration, add your encrypted Firebase token to your .travis.yml
, all other information is read from your firebase.json
:
deploy:
provider: firebase
token:
secure: "YOUR ENCRYPTED token"
Generate Firebase tokens #
Generate your Firebase token after installing the Firebase tools by running:
# This generates a token, e.g. "1/AD7sdasdasdKJA824OvEFc1c89Xz2ilBlaBlaBla"
firebase login:ci
# Encrypt this token
travis encrypt "1/AD7sdasdasdKJA824OvEFc1c89Xz2ilBlaBlaBla" --add
# This command may generate a warning ("If you tried to pass the name of the repository as the first argument, you probably won't get the results you wanted"). You can ignore it.
When using travis encrypt --add
you are likely to receive WARNING: The name of the repository is now passed to the command with the -r option
(see https://github.com/travis-ci/travis-ci/issues/7869). The token will be added to your .travis.yml
, regardless. Inspect and move the token to the secure:
section of your .travis.yml
if it isn’t added there.
Remember to encrypt the token before adding it to your .travis.yml
Deploy to a custom project #
To deploy to a different project than the one specified in the firebase.json
, use the project
key in your .travis.yml
:
deploy:
provider: firebase
token:
secure: "YOUR ENCRYPTED token"
project: "myapp-staging"
Add Deployment Messages #
To add a message to describe the deployment, use the message
key in your .travis.yml
:
deploy:
provider: firebase
token:
secure: "YOUR ENCRYPTED token"
message: "your message"
Run Commands Before or After Deploy #
Sometimes, you want to run commands before or after deploying. You can use
the before_deploy
and after_deploy
stages for this. These will only be
triggered if Travis CI is actually deploying.
before_deploy: "echo 'ready?'"
deploy:
..
after_deploy:
- ./after_deploy_1.sh
- ./after_deploy_2.sh