Spike: Allow CI/CD mirroring to handle forks on GitHub SCM issue

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Based on the following comment #5667 (comment 441462875) we would like to set a spike issue to conduct a short POC and clear some uncertainties:

If refs/pull/*/head are fetched as refs/merge-requests/*/head with project.repository.commits('refs/merge-requests/_id/head', limit: 1), we need to ensure that:

  • updating the mirror would push any refs/pull/*/head to the remote as refs/merge-requests/*/head
  • We should be able to verify that the above worked as expected by fetching the ref: git fetch origin merge-requests/1/head:mr-1 && git checkout mr-1 on a cloned GitLab.
  • Then, for any pull_request and subsequent synchronize webhooks received we should save the ref in the form refs/pull/*/head in ExternalPullRequest model.
  • Provide a method ExternalPullRequest#gitlab_ref that would translate it to refs/merge-requests/*/head and used as ref in ExternalPullRequest::CreatePipelineService. This means that the new pipeline would have ref as refs/merge-requests/*/head
  • Runners should be able to fetch the ref refs/merge-requests/*/head and do the work

We could potentially make also the same-repo pull requests (supported today) to use the res/merge-requests/*/head instead of the current source_ref. So, we have the same strategy for both same-repo and fork PRs.

Expected outcome

Since the purpose of this issue is to allocate some engineering time to break this issue properly so we’ll come better prepared for the next iteration the expected outcome is:

  • List of broken issues of how we can iterate through this existing issue
Edited by 🤖 GitLab Bot 🤖