Firebase action-hosting-deploy 因 RequestError 失败(资源无法通过集成访问)

ppt*_*ppt 39 firebase firebase-hosting github-actions

Firebase action-hosting-deploy 因 RequestError 失败(资源无法通过集成访问)

我正在尝试按照https://firebase.google.com/docs/hosting/github-integration开始自动推送我的代码以由 Firebase 托管。

我最终得到了一个 Github Actions .yml 文件,如下所示:

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
'on': pull_request
jobs:
  build_and_preview:
    if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
    runs-on: ubuntu-latest
    environment: development
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: |
          cd front
          echo "$ENV_DEVELOPMENT" > .env.development
          PWD=$(pwd)
          npm install
          sh -ac ". $PWD/.env.development; npm run build"
        env:
          ENV_DEVELOPMENT: ${{ secrets.ENV_DEVELOPMENT }}
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_MYPROJECT }}'
          projectId: myproject
Run Code Online (Sandbox Code Playgroud)

它运行良好,直到最后一个破折号,即uses: FirebaseExtended/action-hosting-deploy@v0

我收到此错误:

Run FirebaseExtended/action-hosting-deploy@v0
/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:3759
                const error = new RequestError(message, status, ***
                              ^

RequestError [HttpError]: Resource not accessible by integration
    at /home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:3759:31
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async createCheck (/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:5680:17)
    at async run (/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:11435:14) ***
  status: 403,
  headers: ***
    'access-control-allow-origin': '*',
    ...
    'x-xss-protection': '0'
  ***,
  request: ***
    method: 'POST',
    url: 'https://api.github.com/repos/mygithubuser/myproject/check-runs',
    headers: ***
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-core.js/3.2.4 Node.js/16.16.0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    ***,
    body: '***"name":"Deploy Preview","head_sha":"27df35c365f7289ac219329aeb45824ac2fde64a","status":"in_progress"***',
    request: ***
      agent: Agent ***
        _events: [Object: null prototype] ***
          free: [Function (anonymous)],
          newListener: [Function: maybeEnableKeylog]
        ***,
        _eventsCount: 2,
        _maxListeners: undefined,
        default port: 443,
        ...
        maxCachedSessions: 100,
        _sessionCache: ***
          map: ***
            'api.github.com:443:::::::::::::::::::::': [Buffer [Uint8Array]]
          ***,
          list: [ 'api.github.com:443:::::::::::::::::::::' ]
        ***,
        [Symbol(kCapture)]: false
      ***,
      hook: [Function: bound bound register]
    ***
  ***,
  documentation_url: 'https://docs.github.com/rest/reference/checks#create-a-check-run'
***
Run Code Online (Sandbox Code Playgroud)

起初,我认为这是我的云服务工作线程上的权限错误,但如果我进入 console.cloud.google.com 访问 IAM,我可以看到一个 github-action,其角色为“API Keys Viewer”、“Cloud Run Viewer” 、Firebase 身份验证管理员和 Firebase 托管管理员'。为了看看是否有所不同,我还添加了所有者角色。

我可以尝试其他建议吗?

pin*_*der 78

我也遇到了这个错误,所以我为解决该问题所做的事情是:

  1. 在你的 github repo 上点击设置
  2. 单击操作,然后单击常规
  3. 查找工作流程权限部分
  4. 选择第一个选项“读写权限”,然后选中“允许 GitHub Actions 创建和批准拉取请求”复选框,请参阅随附的文件以供参考

在此输入图像描述

如果这也能解决您的问题,请告诉我。

  • @Xin,因为它需要在 firebase 托管上部署 PR 副本,所以 github 令牌需要具有写入权限 (3认同)
  • 这确实解决了。谢谢。还好奇为什么除了读之外还需要写权限?如果你也知道的话? (2认同)

dga*_*ma3 10

试试这个:确保启用 GITHUB_TOKEN 的读写权限。为此,请单击您的 github 组织(不是存储库)、设置、操作、常规,向下滚动到工作流程权限