Skip to content

Instantly share code, notes, and snippets.

@lukepighetti
Last active June 10, 2022 07:49
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lukepighetti/dca8d731aa95adfa86fd01b0c76222d5 to your computer and use it in GitHub Desktop.
Save lukepighetti/dca8d731aa95adfa86fd01b0c76222d5 to your computer and use it in GitHub Desktop.
Flutter Web + GitHub Actions + Firebase Hosting Preview Channels

Three insanely easy steps to getting PR previews with Flutter Web + GitHub + Firebase Hosting Preview Channels

  1. firebase init hosting
  2. say yes to GitHub, production deploy can be either
  3. merge the secrets that Firebase generates in the generated example GitHub action with the one provided here, namely FIREBASE_SERVICE_ACCOUNT_MY_PROJECT_ID and MY_PROJECT_ID
  4. I chose to remove the generated example actions
# .github/workflows/dart.yml
name: build
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "12.x"
- uses: subosito/flutter-action@v1
with:
channel: dev
- run: flutter pub get
- run: flutter pub run build_runner build
- run: flutter build web --release
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_MY_PROJECT_ID }}"
projectId: MY_PROJECT_ID
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
@ramah
Copy link

ramah commented Mar 13, 2021

Hi.
First, Thank you for this gist.
I've found this and I gave it a try
It seems that channelid: live maybe required?
Do you know how to get rid of
--> This action runs on a fork and not found auth token, Skip deployment <---
Thank you

@lukepighetti
Copy link
Author

lukepighetti commented Mar 13, 2021

I haven't run into that issue. I only have one action, the one above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment