Skip to content

Instantly share code, notes, and snippets.

@talamaska
Forked from lukepighetti/dart.yml
Created March 12, 2021 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talamaska/28ff8065616b4b1c2ab2f7583df14149 to your computer and use it in GitHub Desktop.
Save talamaska/28ff8065616b4b1c2ab2f7583df14149 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