firebasegithub-actionsfirebase-hosting

Firebase action-hosting-deploy fails with RequestError (Resource not accessible by integration)


Firebase action-hosting-deploy fails with RequestError (Resource not accessible by integration)

I am trying to follow https://firebase.google.com/docs/hosting/github-integration to start automatically pushing my code to be hosted by Firebase.

I've ended up with a Github Actions .yml file that looks like this:

# 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

It runs well until the last dash, i.e. uses: FirebaseExtended/action-hosting-deploy@v0.

I get this error:

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'
***

At first, I thought this is a permissions error on my cloud service worker, but if I go in my console.cloud.google.com to IAM, I can see a github-action with the roles 'API Keys Viewer, Cloud Run Viewer, Firebase Authentication Admin and Firebase Hosting Admin'. To see if makes a difference, I also added the Owner role.

Any other suggestions I could try?


Solution

  • I ran into this error as well, so what i did to resolve the issue are:

    1. On you your github repo click settings
    2. Click actions and then General
    3. Look for Workflow Permission section
    4. choose the first option 'Read and write permission' and then the checkbox 'Allow GitHub Actions to create and approve pull requests' Please see attached file for your reference

    enter image description here

    Let me know if that resolves your problem as well.