Skip to content

Instantly share code, notes, and snippets.

@eilzo
Created July 29, 2023 18:00
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 eilzo/33492a52663b1ca2d972baa6981032f2 to your computer and use it in GitHub Desktop.
Save eilzo/33492a52663b1ca2d972baa6981032f2 to your computer and use it in GitHub Desktop.
Flutter Firebase Deployment GitHub Action
# On pushes or pull requests to the main branch of the repo,
# this action will run `flutter build web`, and deploy the web app
# to the linked Firebase project.
#
# Setup: Firebase Hosting must be set up in your Firebase project.
# See https://firebase.google.com/docs/hosting/github-integration.
#
# Run `firebase init` -> "Set up GitHub Action deploys" in order to generate
# a value for `secrets.FIREBASE_SERVICE_ACCOUNT_MYPROJECT` which this
# script needs. Running `init` will also generate some yaml action files; they
# can be removed and replaced with this one.
#
# Modify FIREBASE_SERVICE_ACCOUNT_MYPROJECT and FIREBASE_PROJECT_NAME (Lines 56/58).
name: Flutter Firebase Deployment
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build_web:
name: Build Flutter (Web)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
flutter-version: '3.10.4' # Replace with your project's version of Flutter.
channel: 'stable'
- run: flutter pub get
- run: flutter config --enable-web
- run: flutter build web
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: web-build
path: build/web
deploy:
needs: build_web
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v1
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: web-build
path: build/web
- name: Deploy to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_MYPROJECT }}'
channelId: live
projectId: $FIREBASE_PROJECT_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment