merge-branch icon indicating copy to clipboard operation
merge-branch copied to clipboard

Resource not accessible by integration

Open benknight135 opened this issue 2 years ago • 2 comments

Received Resource not accessible by integration error when running in workflow.

/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/i3drobotics/phase-dev/merges: 403 - Resource not accessible by integration // See: https://docs.github.com/rest/reference/repos#merge-a-branch (Octokit::Forbidden)
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in `block in call'
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in `on_complete'
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in `call'
	from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
	from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:[13](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:14)0:in `call'
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:[14](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:15)3:in `build_response'
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in `run_request'
	from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in `post'
	from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
	from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:[15](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:16)6:in `request'
	from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in `post'
	from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:[21](https://github.com/i3drobotics/phase-dev/runs/8153921118?check_suite_focus=true#step:15:22)4:in `merge'
	from /action/lib/index.rb:31:in `<main>'

benknight135 avatar Sep 02 '22 10:09 benknight135

I'm also seeing the same issue. I've tried a changing a few permissions on the job to no avail.

dshunfen avatar Oct 28 '22 14:10 dshunfen

I've passed through this issue too and I've made a huge search by a solution.

This log is not even a bit intuitive. But, by the status code response (403), I've guessed that it could be something related to authorization. And it is!

Taking a look on the source code, I've found that it ocurrors when we make a action that our GITHUB_TOKEN is not supposed to do.

Solution: Include this lines on your workflow:

permissions:
      contents: write

It can be at the job scope or at workflow at all.

This behavior can be setted to the whole repositry too. Go to: Settings -> Actions -> General -> Workflow permissions -> Read and write permissions
Captura de tela de 2023-02-02 01-03-25

source: https://docs.github.com/en/actions/security-guides/automatic-token-authentication

PS: github.token is a context copy of GITHUB_TOKEN. So, if you don't understand from where cames this variable, that is the answer.

Fabio-Vicente avatar Feb 02 '23 04:02 Fabio-Vicente