I have a Flutter web app with two Firebase projects: ‘myapp’ and ‘myapp-dev’. Until now, my project had two main files, main.dart
and main_prod.dart
, each containing the following code for the web configuration of the associated Firebase project:
await Firebase.initializeApp(
options: kIsWeb
? const FirebaseOptions(
apiKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
appId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
messagingSenderId: 'XXXXXXXXXX',
projectId: 'myapp',
authDomain: 'myapp.firebaseapp.com',
databaseURL: 'https://myapp.firebaseio.com',
storageBucket: 'myapp.appspot.com',
measurementId: 'G-PCV7JQ9JKP',
)
: null,
);
This worked well, as I had build flavors set up such that --flavor prod
used main_prod.dart
as the target and --flavor dev
used main.dart
, and as such I could build whichever and put the build on the server that we have been using.
Now, however, I want to set up Firebase’s framework-aware hosting. I did this for the dev environment first, and it all went very smoothly, it made workflow files, and the app can be found on myapp-dev.web.app after a single firebase deploy --only hosting
.
When I switched to the prod project (firebase use prod
), the command firebase deploy --only hosting
still targets main.dart
, and this causes myapp-dev to be deployed to myapp.web.app, which is not what I want. Additionally, trying firebase init hosting
yields an error in the following step:
? For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) myUserName/myProjectName
Error: HTTP Error: 403, Policy update access denied.
My question is: is it possible to configure my project such that running firebase deploy --only hosting
after firebase use prod
deploys myapp to myapp.web.app and running it after firebase use dev
deploys myapp-dev to myapp-dev.web.app? And could I have another GitHub workflow for the prod project next to the one for the dev project? Or can I only have one? I can imagine that with this feature being experimental, I cannot select the build target yet, so maybe I can make main.dart
aware of which Firebase project I’m building for?