A GitHub action that builds and deploys preview versions of your PRs and links to them.
Add a workflow (.github/workflows/deploy-preview.yml
):
name: Deploy Preview
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: developit/firebase-hosting-preview-action@v1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
firebase-token: "${{ secrets.FIREBASE_TOKEN }}"
use-web-tld: true
This is a deploy key you need to generate using the Firebase CLI locally, so that the action can publish your project.
It's important to store this token as an encrypted secret to prevent unintended access your Firebase project. Here's how:
Adding repo-token: "${{secrets.GITHUB_TOKEN}}"
lets the action comment on PRs with the link to the deploy preview.
If you omit this option, you'll need to find the preview URL in the action's build log.
Many projects need to be built before deployment. The action will run the script you provide here before it deploys anything to Firebase.
By default, it will try to build your project using npm run build
.
By default, deploy preview URLs will link are PROJECT-HASH.firebaseapp.com
. Pass use-web-tld: true
to instead use .web.app
.
The URLs are interchangeable, this option only controls which one the action links to.