Skip to content

car expenses list

car expenses list #8

name: Build and Deploy Flutter Web to Firebase Hosting
on:
push:
branches: [analytics_view]
# tags:
# - 'v*.*.*'
pull_request_target:
branches: [analytics_view]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v2
# Set up Java (required by Flutter for Android builds)
- uses: actions/setup-java@v1
with:
java-version: "12.x"
# Set up Flutter using subosito/flutter-action
- uses: subosito/flutter-action@v2
with:
channel: stable
# Verify Flutter setup
- run: flutter --version
# Install Flutter dependencies
- run: flutter pub get
# Build Flutter assets
- run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Create firebase.json
run: |
echo "${{ secrets.FIREBASE_JSON }}" > firebase.json
# Step: Set up Firebase secrets in localStorage
- name: Set up Firebase secrets in localStorage
run: |
echo "window.localStorage.setItem('FIREBASE_API_KEY', '${{ secrets.APIKEY }}');" >> ./web/firebase_config.js
echo "window.localStorage.setItem('FIREBASE_AUTH_DOMAIN', '${{ secrets.AUTHDOMAIN }}');" >> ./web/firebase_config.js
echo "window.localStorage.setItem('FIREBASE_PROJECT_ID', '${{ secrets.PROJECTID }}');" >> ./web/firebase_config.js
echo "window.localStorage.setItem('FIREBASE_STORAGE_BUCKET', '${{ secrets.STORAGEBUCKET }}');" >> ./web/firebase_config.js
echo "window.localStorage.setItem('FIREBASE_MESSAGING_SENDER_ID', '${{ secrets.MESSAGINGSENDERID }}');" >> ./web/firebase_config.js
echo "window.localStorage.setItem('FIREBASE_APP_ID', '${{ secrets.APPID }}');" >> ./web/firebase_config.js
echo "window.localStorage.setItem('FIREBASE_MEASUREMENT_ID', '${{ secrets.MEASUREMENTID }}');" >> ./web/firebase_config.js
- name: Generate mock firebase_options.dart
run: |
mkdir -p lib
echo "// lib/firebase_options.dart" > lib/firebase_options.dart
echo "class DefaultFirebaseOptions {" >> lib/firebase_options.dart
echo " static const firebaseOptions = FirebaseOptions(" >> lib/firebase_options.dart
echo " apiKey: 'mock-api-key'," >> lib/firebase_options.dart
echo " appId: 'mock-app-id'," >> lib/firebase_options.dart
echo " messagingSenderId: 'mock-messaging-sender-id'," >> lib/firebase_options.dart
echo " projectId: 'mock-project-id'," >> lib/firebase_options.dart
echo " );" >> lib/firebase_options.dart
echo "}" >> lib/firebase_options.dart
# Build Flutter Web
- run: flutter build web -t lib/main.dart --release
# Firebase Hosting deploy
- name: Deploy to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_CARLOG_WEBSITE }}"
projectId: "${{ secrets.PROJECTID }}"
channelId: live
preview: false
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks