Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I deploy to different firebase environments using github actions and w9jds/firebase-action

I'm trying to set up CI to firebase for my angular project using Github Actions, but I have both a staging and production environment and I want to deploy to each of them according to which branch I pushed to.

I know that I can create two different workflow scripts for my master and dev branches, but I can't figure out how to deploy to the different firebase environments using w9jds/firebase-action.

When I use the script:

on:
  push:
    branches:
      - dev

jobs:
  build:
    name: 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-prod
      - name: Archive Production Artifact
        uses: actions/upload-artifact@master
        with:
          name: dist
          path: dist
  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: dist
          path: dist
      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting:staging
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

I get the following error:

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

Run firebase use <alias> with one of these options:

  production (#####)
  staging (#####)

What am I doing wrong?

like image 759
A Halverson Avatar asked Jun 15 '20 21:06

A Halverson


People also ask

Can you deploy with GitHub actions?

GitHub Actions offers features that let you control deployments. You can: Trigger workflows with a variety of events. Configure environments to set rules before a job can proceed and to limit access to secrets.


Video Answer


1 Answers

I think you need:

with:
  args: deploy --only hosting --project staging

The hosting:* deploy target is for multiple sites in the same project, to specify a project you should use --project or -P.

like image 161
Michael Bleigh Avatar answered Nov 15 '22 07:11

Michael Bleigh