Search code examples
angularfirebasefirebase-hostinggithub-actions

Deploying Angular App to Firebase Hosting Github Actions


I'm trying to use Github actions to deploy my Angular app to Firebase hosting. I'm using this action in order to accomplish this. My release.yml file looks like the following:

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 }}

However when I commit this onto the master branch, I get the following error:

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

I have no clue what this error means, so any help would be great. Thanks!


Edit: My firebase.json looks like the following:

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

Solution

  • I seemed to have fixed the issue by just simply removing the second section of hosting turning this:

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

    into the following:

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

    I'm not sure if there is any side effects to do this, but it seems to be working fine.