Flutter Web을 Firebase Hosting을 통해 hosting 하는 방법 - (깃헙 pr, merge 시 변경 내용 자동 적용)
1. firebase project 생성: firebase에서 안내해 주는대로 프로젝트를 생성한다.
2.
sudo npm install -g firebase-tools
firebase login
firebase init
3. firebase init 하면 물어보는 질문이 뜨는데, hosting을 스페이스바를 이용해 선택하고 엔터를 눌러 주면 된다.
4. Please select an option에서 Use an exsiting project를 해주고, 1에서 생성한 firebase project를 선택해 준다.
5. What do you want to use as your public directory?에는 build/web 을 작성해 준다.
(아래부터는 깃헙 pr, merge 시 변경 내용 자동 적용)
6. Set up automatic build and deploys with Github? 하면 y를 입력해 주고, github 로그인 후, 해당 작업의 github repository를 입력해 준다.
7. What script should be run before every deploy?에는 아래를 입력해 준다.
sudo snap install flutter --classic && flutter channel beta && flutter co
nfig --enable-web && flutter build web
8. Set up automatic deployment to your site's live channel when a PR is merged? 에 y를 입력해 준다.
9. What is the name of the GitHub branch associated with your site's live channel? 에는 나는 main을 입력해 주었다.
그럼 firebase init이 끝났고, 위 방법은 pr과 merge 시에 모두 반영이 되게 해 주기 때문에,
github에서 merge 시에만 반영이 되고 싶게 하려면,
해당 repository의 action에 들어가서 Deploy to Firebase Hosting on PR을 disable 해 주면 된다.
'Flutter' 카테고리의 다른 글
펫트너 일기 - Flutter Firebase Dynamic Link 앱 설치 트래킹 하기 with Posthog 포스트호그 (0) | 2021.03.25 |
---|---|
Posthog + Flutter firebase dynamic link로 앱 설치 트래킹 하기 (0) | 2021.03.22 |