4

I'm trying to automate the deployment of a react app to firebase with github actions but i'm getting the following error:

Error: Autorization failed. This account is missing the following required permissions on project ***
 firebase.projects.get
 firebasehosting.sites.update

I have multiple sites and when I try to deploy manually using firebase deploy --only hosting:MY_SITE_NAME it's working correctly. I have two jobs in my workflow. The build job passes but the deploy one fails. Here's my workflow file:

name: Build and Deploy to Firebase
on:
  push:
    branches:
      - master

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master
      - name: Install Dependencies
        run: yarn install
      - name: Build
        run: yarn 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
      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting:MY_SITE_NAME
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

Does anyone have an idea of what is wrong?

2
  • How exactly did you configure the account that you want to use for deployment with the Firebase CLI? Feb 24, 2020 at 16:43
  • You mean locally? I ran the commands from firebase-tools. firebase login, then firebase init. Then I selected the project.
    – Merha
    Feb 24, 2020 at 16:49

1 Answer 1

4

If you want to use the Firebase CLI in a CI/CD environment such as GitHub Action, you'll have to provide a way for the CLI to know the account credentials it should use. When you run locally, it can get the credentials from your interaction with firebase login. But when you run elsewhere, there is no UI to prompt you.

You will have to follow the instructions in the documentation on integrating with CI/CD system, and provide a token for the account that should be used to authorize the deployment.

4
  • Yes, I did that too. Sorry I forgot to mention it. I added the token in Github as a secret. i'm using it here FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
    – Merha
    Feb 24, 2020 at 17:01
  • The error message is telling you that the account represented by that token simply doesn't have the required permissions. What have you done to ensure that it has permission? Feb 24, 2020 at 17:33
  • 2
    You were right. I'm so silly. When I ran the firebase login:ci command, firebase was opening a chrome tab from the wrong account Chrome window (I had two different sessions opened) and I didn't even see it when I clicking to log in... Anyway thanks a lot for your help mate!
    – Merha
    Feb 24, 2020 at 17:44
  • firebase login:ci is going to be deprecated soon. How to authenticate using other methods?
    – Aseem
    Jun 18 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.