-
Notifications
You must be signed in to change notification settings - Fork 6
Deploying a fork to Firebase
If your lab plans on deploying this task to your own Firebase, but you do not expect to develop further changes and only deploy changes as developed by Brown, then these instructions are for you!
The first step consists of creating a fork of this repository that you will use to add Firebase configuration changes and trigger the automation for deployement.
To create a fork, first click on the fork button on the upper right corner of the repository's landing page
![fork-repo](https://user-images.githubusercontent.com/1238840/196708638-1278aa6c-3e3d-4416-a8c7-1e7711e1d8cd.png)
You will be asked for the owner, name of the fork and whether to fork only the main branch or all branches.
![forking-questions](https://user-images.githubusercontent.com/1238840/196708203-8ab699ea-f4fa-42e0-a1b3-ab8cbf87a657.png)
- When forking the repository you may be asked to install GitHub Desktop App. This is a convenient way to do it, so follow those instructions.
- Forking only the main branch is sufficient
- Make sure that if you work in a lab you chose the lab's organization as the owner
Now that you have a fork in you lab's Github org, you want to clone that fork into your local computer to start making few changes.
In Github, expand the Code
dropdown and select Open with GitHub Desktop
![image](https://user-images.githubusercontent.com/1238840/196711965-20850c8f-4f74-428d-a98b-5b7599560a3e.png)
In addition to the location to save your clone, you will also be asked how you'll be using this fork. Select, for my own purposes
and then Continue
![image](https://user-images.githubusercontent.com/1238840/196709824-a2f868a3-721f-4e78-abde-9273e8178def.png)
- If your fork is out of sync, you can syn it following these instructions
To create a project, first visit the firebase console - https://console.firebase.google.com. Look for the +
icon
![image](https://user-images.githubusercontent.com/1238840/196713720-19daae64-73db-4ff9-b009-5b51d99a79e4.png)
Fill up the details and continue with prompts. (Google Analytics can be disabled)
![image](https://user-images.githubusercontent.com/1238840/196713980-9d096b2a-eceb-4e77-89fa-00c903114da0.png)
- Install the Firebase Command Line Tools . Instructions here
In Github Desktop App, select Branch -> New. Type your lab name, and select to start it from main
![image](https://user-images.githubusercontent.com/1238840/196714590-c5a547d8-f212-43cb-8e85-0e6601dc36e6.png)
You can then publish your new branch and open your code on VSCode
![image](https://user-images.githubusercontent.com/1238840/196716599-bb6ca40b-ca71-4c3f-87f2-2f5eaa3612ca.png)
At this point you will need to add a new file (or use an existing one if there is already a file with your lab's name). You will need to fill-in the environment variables needed for deployment in a env/.env.firebase-<lab>
file. If there is not a file for your lab in the .env
folder, then make a copy of env/.env.firebase-lncc
, replace lncc
in the filename with your lab's name, and change the variables inside for your firebase project.
To find the Firebase details for your project, follow the instructions detailed here
Caution: The filename pattern is important, make sure it's called .env.firebase-<yourlab>
, where <yourlab>
is appropriately substituted
The correct project-id is needed inside the .firebaserc
and .github/workflows/firebase-hosting-merge.yml
If these operations aren't very familiar to you, please use the GitHub Desktop App as it will set up the correct branches in the remote to track for you in an intuitive way.
Note: You should not merge this branch to main
branch. In the future, you will be bringing changes from the main
branch to your branch and this is where you'll work and deploy from.
As a reference, your commits should be very similar to these
Follow these instructions if you need to download/install the Firebase Command Line Tools With the terminal open in your branch, type
firebase login
Then type:
firebase init hosting:github
You may need to grant Firebase access to your Github organization or user. Read instructions in the command prompts carefully. Follw all questions, these may look as follows:
For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) brown-ccv/task
-effort
✔ Uploaded service account JSON to GitHub as secret FIREBASE_SERVICE_ACCOUNT_TASK_EFFORT_CCV.
i You can manage your secrets at https://github.com/brown-ccv/task-effort/settings/secrets.
? Set up the workflow to run a build script before every deploy? (y/N) No
? GitHub workflow file for PR previews exists. Overwrite? firebase-hosting-pull-request.yml No
? Set up automatic deployment to your site's live channel when a PR is merged? No
i Action required: Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:
https://github.com/settings/connections/applications/89cf50f02ac6aaed3484
i Action required: Push any new workflow file(s) to your repo
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
Although we didn't generate new workflows, this process created a service account as a secret in your github project that will be used for deployment. To confirm, in GitHub visit Settings -> Secrets
- Note the name of your service account printed after the first question, in this example it was
FIREBASE_SERVICE_ACCOUNT_TASK_EFFORT_CCV
. - Update the file
.github/workflows/firebase-hosting-merge.yml
around line 48 to match your service account name. - Commit and push. Your changes should look similar to these
Go to the actions tab and enable them
Select firebase-deploy-merge-demand, and run workflow. Make sure to apply following changes
- Choose your lab's branch.
- Type suffix for your lab's environment file
- Choose
qa
channel.
In our case the dialog looks as follows
If deployment works, your action will get a green check mark
You can click on your action and explore your logs. Under the action-deploy-host
step and look for the temporary url. Visit that url and confirm the behavior of your task
Once you have confirmed that your task is working as expected, you can re-run the firebase-deploy-merge-demand
action but this time deploy to the "live" channel