github actions firebase No project active, but project aliases are available

Viewed 223

I have created a workflow to build react app to the production.

name: Build and Deploy
on:
  push:
    branches:
      - main

jobs:
  build:
    name: Build
    env:
      REACT_APP_ENV: live build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Install Dependencies
        run: npm install
      - name: Build
        run: npm run build
      - name: Archive Production Artifact
        uses: actions/upload-artifact@master
        with:
          name: build
          path: build
  deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Download Artifact
        uses: actions/download-artifact@master
        with:
          name: build
          path: build
      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting:production
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

Build job is running correctly. But for the deploy, I got this error

Error: No project active, but project aliases are available.

Run firebase use with one of these options:

My .firebaserc file

{
  "projects": {
    "production": "gottamenu-admin",
    "development":"gotta-menu-ap"
  }
}

I follow instructions on the firebase repo for GitHub actions

If you have multiple hosting environments you can specify which one in the args line. e.g. args: deploy --only hosting:[environment name]

That's why I put args: deploy --only hosting:production

How do I fix this error in GitHub action?

1 Answers

Use deploy --only hosting:production if you want to deploy different sites (targets) on the same firebase-project

And your .firebaserc should look like

{
  "projects": {
    "default": "gottamenu-admin"
  },
  "targets": {
    "gottamenu-admin": {
      "hosting": {
        "production": [
          "gottamenu-admin",
        ],
        "development": [
          "gotta-menu-ap"
        ]
      }
    }
  }
}

If you want to deploy to different firebase-projects then your .firebaserc file is correct but you should use deploy -P production or deploy --project production

Related