将Angular应用部署到Firebase托管Github Actions

3

我试图使用Github Actions将我的Angular应用程序部署到Firebase托管。为了实现这一目的,我使用了操作。我的release.yml文件如下所示:

name: Release
on:
  push:
    branches:
      - master

jobs:
  firebase-deploy:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
    - uses: actions/setup-node@master
      with:
        node-version: '14.x'
    - run: npm install
    - run: npm run build --prod
    - uses: w9jds/firebase-action@master
      with:
        args: deploy --only hosting
      env:
        FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

然而,当我将其提交到master分支时,出现以下错误:

错误:必须在每个“hosting”配置中提供“site”或“target”之一。

我不知道这个错误是什么意思,所以任何帮助都将是极好的。谢谢!


编辑:我的firebase.json如下所示:

{
  "hosting": [
    {
      "public": "MyName",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "projectName",
      "public": "dist/projectName",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ]
}

你是否有多个托管站点?你需要在firebase.json文件中指定部署目标。https://firebase.google.com/docs/cli/targets#configure_your_firebasejson_file_to_use_deploy_targets - cwlau
请查看我编辑后的答案 @cwlau - Gabe
1个回答

3

我似乎通过简单的移除托管的第二个部分来解决了这个问题,将其从以下内容:

{
  "hosting": [
    {
      "public": "MyName",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "projectName",
      "public": "dist/projectName",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ]
}

请问您需要翻译的内容是什么?

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

我不确定这样做是否会有任何副作用,但看起来它运行良好。


这对我完美地起作用了!谢谢! - Matt S

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接