将 Angular 应用程序部署到 Firebase 托管 Github 操作

Deploying Angular App to Firebase Hosting Github Actions

我正在尝试使用 Github 操作将我的 Angular 应用程序部署到 Firebase 托管。我正在使用 this 操作来完成此操作。我的 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 分支时,出现以下错误:

Error: Must supply either "site" or "target" in each "hosting" config.

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


编辑:我的 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"
        }
      ]
    }
  ]
}

我似乎只是简单地删除了托管的第二部分就解决了这个问题:

{
  "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"
        }
      ]
    }
  ]
}

我不确定这样做是否有任何副作用,但它似乎工作正常。