为CI / CD开发人员和产品站点的相同存储库为不同项目设置不同的Firestore数据库

问题描述

我有两个具有CI / CD管道的firebase项目,如果我要掌握和开发,如果要推动我的开发分支,它会部署到生产中。我的.firebasesrc就像这样:

{
  "projects": {
    "default": "host-test-xxxxx"
  },"targets": {
    "host-test-xxxxx": {
      "hosting": {
        "production": [
          "production-xxxxx"
        ]
      }
    },"host-test-dev": {
      "hosting": {
        "develop": [
          "develop-xxxxx"
        ]
      }
    }
  }
}

而我的firebase.json是:

{
  "hosting": [{
    "target": "develop","public": "build","ignore": [
      "firebase.json","**/.*","**/node_modules/**"
    ],"rewrites": [
      {
        "source": "**","destination": "/index.html"
      }
    ]
  },{
    "target": "production","destination": "/index.html"
      }
    ]
  }
]
}

目标当前设置为默认,并且我在该项目中设置了一个Firestore。我想创建一个获取当前目标配置的文件,如下所示:

import * as firebase from 'firebase';
import 'firebase/firestore';

const firebaseConfig = {
    apiKey: "$myAPIKEY",projectId: "$myPROJECTID",appId: "$myAPPID",};

firebase.initializeApp(firebaseConfig);


export default firebase;

我很困惑如何从项目中获取此信息。如果我使用Google Cloud build触发器变量更改项目ID,则我希望此信息有所不同,这样,如果我将其部署到生产环境中,则可以在生产项目中获取数据库,而如果要进行开发,则可以获取开发数据库。 / p>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)