How to auto merge pr from fork

I have been working on a project like first-contribution. Where newcomers have to commit a new file with their name into the repo. For this, I am trying to make a GitHub action which auto-merge the pr if every check has passed. I am using pascalgn/automerge-action for the same purpose.

It gives Failed to merge PR: Resource not accessible by integration error if someone from outside the organization opens a pr. After reading on the internet I learn that the problem is forks do not have a write permission to the repo and their pr can not get auto merged. PR form the organization’s owner or member get merged automatically but not from an outsider.

After reading this I have ticked first two options under organization settings but it’s still not working and gives the same error.

Thank you.

What “on” event are you using?

Assuming you mean your “first-bit” repo then you need to use pull_request_target as your on event (vs. pull_request).

For your checkout you want to make sure you checkout the PR content:

    - name: Checkout
      uses: actions/checkout@v2
        ref: ${{github.event.pull_request.head.ref}}
        repository: ${{github.event.pull_request.head.repo.full_name}}
1 Like

@Janglee123 ,

Yes, I can reproduce the same issue.
I also tried other similar actions that wrap the “Merge a pull request” API, get the same error message “Resource not accessible by integration”.
I directly run the “Merge a pull request” API in the workflow, get the same error message “Resource not accessible by integration”.

Looks like, the feature “Run workflows from fork pull requests” does not work as designed.
I have created an issue ticket (actions/virtual-environments#1609) to report this issue to the appropriate engineering team for further investigation and evaluation.

You can follow this issue ticket and add your comments to it.

1 Like

@Janglee123 Hi! Thank you for reporting this. Is the repository you’re trying to merge the pull request into public or private?

@jclem Thanks for your interest, The repo is public.

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)