Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caught error trying to update branch: Resource not accessible by integration #19

Closed
shobhitagarwal1612 opened this issue Apr 14, 2020 · 6 comments

Comments

@shobhitagarwal1612
Copy link

shobhitagarwal1612 commented Apr 14, 2020

Hey. We were trying out the action in our project and it doesn't update the branch in PR (which belongs to a forked project) whenever a commit gets pushed to the repository.

I see the following error in the Actions tab

Handling push event on ref 'refs/heads/master'
PR-425
  Evaluating pull request #425...
  PR_FILTER=all, checking if this PR's branch needs to be updated.
  All checks pass and PR branch is behind base branch.
  Updating branch 'testing' on pull request #425 with changes from ref 'master'.
  Attempting branch update...
  ##[error]Caught error trying to update branch: Resource not accessible by integration
  Branch update failed, will retry in 300ms, retry #0 of 5.
  Attempting branch update...
  ##[error]Caught error trying to update branch: Resource not accessible by integration
  Branch update failed, will retry in 300ms, retry #1 of 5.
  Attempting branch update...
  ##[error]Caught error trying to update branch: Resource not accessible by integration
  Branch update failed, will retry in 300ms, retry #2 of 5.
  Attempting branch update...
  ##[error]Caught error trying to update branch: Resource not accessible by integration
  Branch update failed, will retry in 300ms, retry #3 of 5.
  Attempting branch update...
  ##[error]Caught error trying to update branch: Resource not accessible by integration
  Branch update failed, will retry in 300ms, retry #4 of 5.
  Attempting branch update...
  ##[error]Caught error trying to update branch: Resource not accessible by integration
  ##[error]Resource not accessible by integration

We are using the default yml config as mentioned in the documentation

Is this a limitation of this Github Action? Any help is really appreciated. Thanks!

@chinthakagodawita
Copy link
Owner

Hey @shobhitagarwal1612 - this might be because the source branch (where the changes are being pulled form) are in a separate repository and the token you've provided to autoupdate doesn't have access to write to that repository.

If this is the case, one possible workaround is to create a personal access token that has write access to both repositories and pass that in instead. I've personally set some repositories up like this due to similar limitations.

To obtain a valid access token follow this link and make sure it has access to both repositories: https://github.com/settings/tokens/new?scopes=repo&description=autoupdate-action

Then add this to the repository that has autoupdate installed as a secret - https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets

(remember the name you give this secret, you'll need it below!)

Finally, change the autoupdate.yaml file to reference this secret.

i.e. instead of:

        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

you'd do:

        env:
          GITHUB_TOKEN: "${{ secrets.MY_SECRET_NAME }}"

Let me know how you go!

@shobhitagarwal1612
Copy link
Author

@chinthakagodawita Thanks for the quick reply!

So this needs to be done for each of the forked repositories that have opened PR to the base repo, right? It doesn't seem feasible for an open source project where the number of contributors vary a lot.

@chinthakagodawita
Copy link
Owner

Yes, unfortunately that is a limitation of how actions operate - they have to authenticate somehow, either using a personal access token generated by a Github account or via the auto-generated token on the repository.

For autoupdate to work, it needs access to write to the PR's branch.

You could try the following, instead of running on an event trigger, this will run the update on a schedule. This gets around the limitation where the base branch push event originates on a different repository than the PR branch. It also requires the autoupdate.yaml file to exist on the fork, i.e. the fork must have been created (or synced) after you add the workflow yaml file.

  • Use the repository token instead of a generated PAT (i.e. GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}")
  • Update the autoupdate.yaml to look like:
name: autoupdate
on:
  # This will trigger every 30mins (tweak this as required)
  schedule:
    - cron: '*/30 * * * *'
jobs:
  autoupdate:
    name: autoupdate
    runs-on: ubuntu-18.04
    steps:
      - uses: docker://chinthakagodawita/autoupdate-action:v1
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
  • Make sure the fork is up to date

@Borda
Copy link

Borda commented Jan 12, 2021

Hi @chinthakagodawita, I have a follow-up question it seems that after trying to work forked PR which is very common in opensource the bot just dies, right? so even there are other PR it could resolve it just stop with reaching the first difficult PR...
So would it be possible to change this error as a warning (eventually add an argument such as "continue-if-fails") and continue with other PRs?

just for the record, created a new issue: #100

@RishabhJain2018
Copy link

RishabhJain2018 commented Apr 4, 2021

Hey @chinthakagodawita ,
I was trying to use schedule in the config and received this error --
image

Am I missing something?
Here is the config -- https://github.com/Cloud-CV/EvalAI/blob/master/.github/workflows/autoupdate.yaml

@anarast
Copy link
Collaborator

anarast commented Apr 10, 2021

Hey @RishabhJain2018, autoupdate doesn't currently support the schedule event. I'll create a new issue for it and we'll look into it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants