Support Review App Pipelines for MRs from Forks
With the changes in Pass additional variable to docs review pipeline (gitlab!112992 - merged) we can change the clone_repositories task in a way that it checks out the actual MR instead of the branch. This allows to spin up a review app for MRs which come from a fork and therefore don't have their branch in the canonical repository.
Git can't clone something else than a branch directly. So we need to use the following procedure:
- Create an empty directory for the project
- Use
git init
inside - Add the remote
- Fetch the refspec
- Checkout the FETCH_HEAD
Important: I have only tested the path where we have a review app. I didn't want to try to simulate stable branches since I think that it could break things.
Test run: https://gitlab.com/gitlab-org/gitlab/-/jobs/3833386341 (triggered https://gitlab.com/gitlab-org/gitlab-docs/-/pipelines/788650392)
Btw. this problem bothered me a long time already since I have seen some of you trigger the review app on my MRs and have it fail because the branch didn't exist in the canonical project. But I could not fix it until now, because I couldn't trigger the job/pipeline myself