Firebase 为不同的项目设置不同的firestore数据库,并为CI/CD开发和产品站点设置相同的回购协议
我有两个firebase项目,其中有一个CI/CD管道,如果我推动master,它将部署到生产,如果我推动develop分支,它将部署到develop。My.firebasesrc是这样的:Firebase 为不同的项目设置不同的firestore数据库,并为CI/CD开发和产品站点设置相同的回购协议,firebase,google-cloud-firestore,google-cloud-build,Firebase,Google Cloud Firestore,Google Cloud Build,我有两个firebase项目,其中有一个CI/CD管道,如果我推动master,它将部署到生产,如果我推动develop分支,它将部署到develop。My.firebasesrc是这样的: { "projects": { "default": "host-test-xxxxx" }, "targets": { "host-test-xxxxx": { &q
{
"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",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"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,我希望这些信息有所不同,这样,如果我部署到生产项目,我将获得生产项目中的数据库,如果我部署到开发项目,我将获得开发数据库。请查看以下内容。请让我知道它是否适用于您,因为如果不是用于云功能,它不是专门用于云构建的。我想我确实看到了这一点,并使用了类似的方法。我会在某个阶段发布我的问题的详细答案,因为我已经解决了这个问题,但解决方案相当复杂,所以我可能会写一篇中间文章和链接之类的东西