Skip to content

Instantly share code, notes, and snippets.

@ramah
Forked from lukepighetti/dart.yml
Created March 12, 2021 16:37
Show Gist options
  • Save ramah/e6ab9b69834dc58af38b3d93128dd6ca to your computer and use it in GitHub Desktop.
Save ramah/e6ab9b69834dc58af38b3d93128dd6ca 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 their example GitHub action with the one provided here, namely FIREBASE_SERVICE_ACCOUNT_MY_PROJECT_ID and MY_PROJECT_ID
# .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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment