Skip to main content

Add GitHub collaborators from a fork PR

Usually, when users need to add GitHub collaborators, someone in the MoJ GitHub Organisation will raise a PR via a branch of the repository.

If there is no such MoJ Organisation member who can do this, someone in the collaborator organisation (who won’t have access permissions to create a branch PR) will raise a PR via a fork instead.

In this case, the GitHub Actions which run on a branch PR will fail with unhelpful messages like this:

Error: error configuring S3 Backend: no valid credential sources for S3 Backend
found.

or:

Running: git status --porcelain=1 --untracked-files=no
/usr/local/bundle/gems/octokit-4.20.0/lib/octokit/response/raise_error.rb:14:in
`on_complete': GET
https://api.github.com/repos/ministryofjustice/github-collaborators/git/refs/heads/made-tech-ima-team:
404 - Not Found // See:
https://docs.github.com/enterprise/2.18/user/rest/reference/git#get-a-reference
(Octokit::NotFound)
from /usr/local/bundle/gems/faraday-0.9.0/lib/faraday/response.rb:9:in `block in call'

To fix this, you need to raise an equivalent PR via a branch.

  • Start in an up to date working copy of the GitHub collaborators repository

  • Get the fork details from the PR. Near the top of the page, you should see something like this:

thip wants to merge 1 commit into ministryofjustice:main from madetech:made-tech-ima-team

Here, the GitHub login which owns the fork is madetech, and their branch of the repository is called made-tech-ima-team

  • Add a remote for the fork
git remote add madetech git@github.com:madetech/github-collaborators
  • Create a new branch
git checkout -b madetech-changes
  • Get the changes from the fork
git pull madetech made-tech-ima-team

At this point, your local branch madetech-changes has the same changes as the fork branch, so you can raise a PR as usual, and all the checks should run successfully.

It’s good practice to reference the fork PR in the branch PR, to make it easier for people to figure out what happened, later.

Once you are happy, merge your PR.

The commits in your branch PR are exactly the commits which are in the fork PR, so (unless you made any other changes), GitHub will show the fork PR as being merged when you merge the branch PR.

If this is not the case (which might happen if you make other changes to the branch PR before merging it), the fork PR should be closed without merging, with a comment pointing to the equivalent branch PR.

This page was last reviewed on 5 June 2024. It needs to be reviewed again on 5 September 2024 by the page owner #operations-engineering-alerts .
This page was set to be reviewed before 5 September 2024 by the page owner #operations-engineering-alerts. This might mean the content is out of date.