diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a8a612e..acd5e17 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 \ No newline at end of file diff --git a/lib/firebase_init.dart b/lib/firebase_init.dart index 16ab6f1..d5f56c3 100644 --- a/lib/firebase_init.dart +++ b/lib/firebase_init.dart @@ -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 initFirebase() async { - await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + await Firebase.initializeApp(options: FirebaseConfig.currentPlatform); getIt().init(); } diff --git a/lib/util/firebase/firebase_config.dart b/lib/util/firebase/firebase_config.dart new file mode 100644 index 0000000..7f29a78 --- /dev/null +++ b/lib/util/firebase/firebase_config.dart @@ -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'), + ); +}