针对 Firebase 多站点托管中的特定站点进行 React js 并使用 github 操作?
所以我有一个 React js,我使用 firebase 来托管该网站。我创建了一个名为“parentproject”的项目,其中包含多个站点“site1”“site2”。 我正在使用 GitHub actions 来检测我的两个分支“prod 和 dev”中的一个的推送。因此,当我推送到 prod 分支时,我想部署在“site1”上,当我推送到 dev 分支时,我想部署在“site2”上。 我也在使用 github 工作流程。我的 firebase 配置是:
.firebaserc
{
"projects": {
"default": "site1"
},
"targets": {
"parentProject": {
"hosting": {
"prod": ["site1"],
"dev": ["site2"],
}
}
}
}
firebase.json
{
"hosting": {
"target": "prod",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
我的推送分支的 yml 文件如下所示:
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- prod
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: npm ci
- run: CI=false npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SECRETKEY }}'
channelId: live
projectId: parentProject
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
每次我推送到 prod 时,我的网站都会部署在默认的 firebase 托管页面上,而不是“site1”。任何建议都有帮助。
So I have a react js and I am using firebase to host the site. And I have created a project named "parentproject" having multiple sites "site1" "site2".
And I am using GitHub actions to detect push on either of my 2 branches "prod and dev". So, when I push into prod branch I want to deploy on "site1" and when I push to dev branch I want to deply on "site2".
I am also using github workflow. My firebase configs are :
.firebaserc
{
"projects": {
"default": "site1"
},
"targets": {
"parentProject": {
"hosting": {
"prod": ["site1"],
"dev": ["site2"],
}
}
}
}
firebase.json
{
"hosting": {
"target": "prod",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
My yml file for push branch looks like:
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- prod
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: npm ci
- run: CI=false npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SECRETKEY }}'
channelId: live
projectId: parentProject
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
Every time I push to prod, my site gets deployed on default firebase hosting page, not "site1". Any suggestion are helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个名为“target”的字段,您可以在其中设置要部署的特定站点,有关详细信息,请参阅 firebase github 操作的文档:https://github.com/FirebaseExtended/action-hosting-deploy#target-string
您还必须在 firebase.json 上添加字段“site” , 喜欢:
There is a field called "target" where you can setup the specific site to deploy, more about it on the documentation of the firebase github action: https://github.com/FirebaseExtended/action-hosting-deploy#target-string
You have to add also the field "site" on the firebase.json, like: