LoginSignup
37
26

More than 5 years have passed since last update.

Cloud Functions for Firebase で deploy 先を切り替える

Posted at

Firebase Project を develop, staging, production など切り替える場合、例えば iOS だったら GoogleService-Info.plist を環境別に切り替えれば良い。

しかしその場合 Cloud Functions の deploy 先もそれぞれ切り替える必要がある。

firebase use --add

このコマンドを打つと、deploy 先を設定できる。

  • ? Which project do you want to add?
    • 対話モードになり、 Firebase Project の一覧が表示される。そこから使うものを1つ選ぶ
  • ? What alias do you want to use for this project?
    • 名称を決める
$ firebase use --add
? Which project do you want to add? development-project
? What alias do you want to use for this project? (e.g. staging) default


$ firebase use --add
? Which project do you want to add? staging-project
? What alias do you want to use for this project? (e.g. staging) staging

すると .firebaserc というファイルが生成される

{
  "projects": {
    "default": "development-project",
    "staging": "staging-project"
  }
}

firebaes use で切り替え

$ firebaes use staging
$ firebase deploy --only functions

これでそれぞれの環境への deploy ができるようになった。

参考

37
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
26