[英]Target particular site among Firebase multiple site hosting for react js and using github actions?
所以我有一個反應 js,我正在使用 firebase 來托管網站。 我創建了一個名為“parentproject”的項目,該項目具有多個站點“site1”“site2”。 我正在使用 GitHub 動作來檢測我的兩個分支“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
每次我推送到產品時,我的網站都會部署在默認的 firebase 托管頁面上,而不是“site1”。 任何建議都是有幫助的。
有一個名為“目標”的字段,您可以在其中設置要部署的特定站點,有關它的更多信息,請參見 firebase github 操作的文檔: https: //tdeploy/target-stringEx.
(...)
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_SECRETKEY }}'
channelId: live
projectId: parentProject
==> target: "<site id here>"
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
您還必須在 firebase.json 上添加“站點”字段,例如:
{
"hosting": {
"target": "prod",
==> "site": "<id of the site in the firebase projet>",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.