【问题标题】:Deploying Angular App to Firebase Hosting Github Actions将 Angular 应用程序部署到 Firebase 托管 Github 操作
【发布时间】:2020-10-20 05:43:45
【问题描述】:

我正在尝试使用 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 分支时,我收到以下错误:

错误:必须在每个“托管”配置中提供“站点”或“目标”。

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


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

【问题讨论】:

标签: angular firebase firebase-hosting github-actions


【解决方案1】:

我似乎已经解决了这个问题,只需简单地删除托管的第二部分即可:

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

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

【讨论】:

  • 这对我来说非常有效!谢谢!
猜你喜欢
  • 1970-01-01
  • 2021-04-23
  • 2021-01-06
  • 2021-05-09
  • 2020-09-25
  • 1970-01-01
  • 1970-01-01
  • 2019-07-11
  • 2020-12-25
相关资源
最近更新 更多