Skip to content

Commit

Permalink
ci(github-actions): Added better build script for the deploy to githu…
Browse files Browse the repository at this point in the history
…b pages
  • Loading branch information
vanlooverenkoen committed Nov 21, 2023
1 parent b4fafa4 commit bbaae74
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
name: Deploy static content to Pages
name: Deploy to github pages

on:
push:
branches: ["main"]

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
- uses: bluefireteam/flutter-gh-pages@v7
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- run: flutter packages get
- run: dart analyze
- run: flutter build web
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './build/web'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
4 changes: 2 additions & 2 deletions lib/firebase_init.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_belgium/di/injectable.dart';
import 'package:flutter_belgium/firebase_options.dart';
import 'package:flutter_belgium/repo/login_repo.dart';
import 'package:flutter_belgium/util/firebase/firebase_config.dart';

Future<void> initFirebase() async {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await Firebase.initializeApp(options: FirebaseConfig.currentPlatform);
getIt<LoginRepository>().init();
}
27 changes: 27 additions & 0 deletions lib/util/firebase/firebase_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
// import 'package:flutter_belgium/firebase_options.dart';

class FirebaseConfig {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return _web;
}
throw UnsupportedError('This platform is not supported');
// try {
// return DefaultFirebaseOptions.currentPlatform;
// } catch (e) {
// return DefaultFirebaseOptions.currentPlatform;
// }
}

static const FirebaseOptions _web = FirebaseOptions(
apiKey: String.fromEnvironment('FIREBASE_API_KEY'),
appId: String.fromEnvironment('FIREBASE_APP_ID'),
messagingSenderId: String.fromEnvironment('FIREBASE_MESSAGING_SENDER_ID'),
projectId: String.fromEnvironment('FIREBASE_PROJECT_ID'),
authDomain: String.fromEnvironment('FIREBASE_AUTH_DOMAIN'),
storageBucket: String.fromEnvironment('FIREBASE_STORAGE_BUCKET'),
measurementId: String.fromEnvironment('FIREBASE_MEASUREMENT_ID'),
);
}

0 comments on commit bbaae74

Please sign in to comment.