firebase hostingをcloud buildからデプロイ
firebase hostingをcloud buildからデプロイした時の備忘録です。
firebaseプロジェクトを作成
昨日の記事です。
firebase hostingでサイトを公開するcloud buildのコミュニティ ビルダーを設定
cf. https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-firebase?hl=ja
git clone https://github.com/GoogleCloudPlatform/cloud-builders-community.git
# firebase用
cd cloud-builders-community/firebase
gcloud builds submit --project <ProjectID> .
# Would you like to enable and retry (this will take a few minutes)? => y
# hugoを使う場合
cd ../hugo
gcloud builds submit --project <ProjectID> .
--config cloudbuild.yaml
はdefaultだから不要
よくあるerror
firebaseの料金プランを従量制にしないとエラーがでる
ERROR: (gcloud.builds.submit) HTTPError 403: The project to be billed is associated with an absent billing account.
Cloud Build APIを有効にしないとエラーがでる
ERROR: (gcloud.builds.submit) User [メアド] does not have permission to access project [ProjectID] (or it may not exist): Cloud Build API has not been used in project <番号> before or it is disabled.
Cloud Build サービス アカウント権限を設定
「Cloud Build」の「設定」から設定します
- Cloud Functions
- Firebase
- Service Accounts
を有効にする (Service Accountsは質問に答える時に有効にすればいい)

Cloud Buildへデプロイ
.gcloudignore
へ記載する
- node_modules/
- .git/
- public/
gcloud builds submit --project <projectID> .