Flutter CI/CD Web host in Firebase using GitHub Action
By Robby
Flutter CI/CD web host in firebase hosting using GitHub Actions
Source code below
firebase init hosting
firebase init hosting:github
Follow the CLI prompts, and the command will automatically take care of setting up the GitHub Action:
- Creates a service account in your Firebase project with permission to deploy to Firebase Hosting.
- Encrypts that service account’s JSON key and uploads it to the specified GitHub repository as a GitHub secret.
- Writes GitHub workflow
yaml
configuration files that reference the newly created secret. These files configure the GitHub Action to deploy to Firebase Hosting.
- run: npm ci && npm run build
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
- name: 'Run flutter pub get'
run: flutter pub get
- name: 'Build Web App'
run: flutter build web
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
- name: 'Run flutter pub get'
run: flutter pub get
- name: 'Build Web App'
run: flutter build web
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_MYPROJECT_2EF32 }}'
channelId: live
projectId: myproject-2ef32
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
https://console.cloud.google.com/apis/library/firebasehosting.googleapis.com
Source Code: https://github.com/Robertrobinson777/flutterweb_cicd