joshmfrankel / simplecov-check-action

SimpleCov+ Action
MIT License
32 stars 16 forks source link

Resource not accessible by integration #11

Closed SirMishaa closed 1 year ago

SirMishaa commented 1 year ago

Hello, at work, I got this issue :

/action/lib/coverage/utils/request.rb:48:in `run': Forbidden: {"message":"Resource not accessible by 
integration","documentation_url":"https://docs.github.com/rest/reference/checks#create-a-check-run"} (RuntimeError)
    from /action/lib/coverage/utils/request.rb:18:in `post'
    from /action/lib/coverage/check_action.rb:8:in `call'
    from /action/lib/main.rb:16:in `<main>'

We're running on an organization, in team plan We're using the following in our workflow:

 jobs:
  build:
    runs-on: buildjet-4vcpu-ubuntu-2204
    permissions:
      id-token: write
      contents: read

 #      - name: Report test coverage
#        uses: joshmfrankel/simplecov-check-action@main
#        with:
#          github_token: ${{ secrets.GITHUB_TOKEN }}

Do you know what happens?

samuele-mattiuzzo commented 1 year ago

Interested as well, as it started failing for us as of today.

joshmfrankel commented 1 year ago

Weird that this just started happening for you.

It sounds like a permissions issue or perhaps a GitHub service issue. From what I've read, the GITHUB_TOKEN contains default permissions which can be found here: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token. Now it also mentions, "People with admin permissions to an enterprise, organization, or repository, can set the default permissions to be either permissive or restricted.". I'd first check that this isn't the case for your organization's configuration.

If that doesn't work, then try overriding permissions within the workflow file.

jobs:
  testing:
    permissions: write-all
    steps:
       ....
       - uses: joshmfrankel/simplecov-check-action@main
       with:
         github_token: ${{ secrets.GITHUB_TOKEN }}

Permissions documentation can be found here.

If that doesn't work then try switching ${{ secrets.GITHUB_TOKEN }} to utilize a personal access token. More details here: https://stackoverflow.com/questions/70435286/resource-not-accessible-by-integration-on-github-post-repos-owner-repo-ac/70448851#70448851

joshmfrankel commented 1 year ago

I'm going to go ahead and close this issue for now. Let me know if the directions above fail to solve the issue

shettytejas commented 1 year ago

I was facing this issue. I solved it by going to repository settings > Actions > General > Workflow permissions and setting Read and Write permissions.