在 Github 操作中部署 Firebase 给出授权失败错误

Firebase deploy in Github Actions gives Authorization failed error

我正在尝试使用 github 操作将 React 应用程序自动部署到 firebase,但出现以下错误:

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

我有多个站点,当我尝试使用 firebase deploy --only hosting:MY_SITE_NAME 手动部署时,它工作正常。我的工作流程中有两个工作。构建作业通过但部署作业失败。这是我的工作流程文件:

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

有人知道哪里出了问题吗?

如果您想在 CI/CD 环境中使用 Firebase CLI,例如 GitHub Action,您必须为 CLI 提供一种方法来了解它应该使用的帐户凭据。当您在本地 运行 时,它可以从您与 firebase login 的交互中获取凭据。但是当你在别处运行时,没有UI提示你

您将必须 follow the instructions in the documentation on integrating with CI/CD system,并为用于授权部署的帐户提供令牌。