feat: fetch fork PR head from base repo in the merge checkout strategy - #6743
Open
meringu wants to merge 1 commit into
Open
feat: fetch fork PR head from base repo in the merge checkout strategy#6743meringu wants to merge 1 commit into
meringu wants to merge 1 commit into
Conversation
In the merge checkout strategy Atlantis clones the base branch and merges the PR head into it. The head was fetched from the PR's "source" remote (the head repo, e.g. a fork), which requires access to the fork — a problem when the GitHub App isn't installed on the fork, or the token is scoped to the base repo. GitHub exposes every PR's head on the base repo as refs/pull/<n>/head, which the App path already uses. Extend that to the merge strategy: when merging a GitHub PR, fetch pull/<n>/head from origin instead of the fork's remote. This lets fork PRs run in merge mode without access to the fork. It is a no-op for same-repo PRs (same commit), and unchanged for the branch strategy and non-GitHub hosts. Signed-off-by: Henry Muru Paenga <meringu@gmail.com>
meringu
force-pushed
the
fork-fetch-via-base-on-merge
branch
from
August 7, 2026 00:09
5dc1e75 to
1d55aaa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the merge checkout strategy Atlantis clones the base branch and merges the PR head into it. The head was fetched from the PR's "source" remote (the head repo, e.g. a fork), which requires access to the fork — a problem when the GitHub App isn't installed on the fork, or the token is scoped to the base repo.
GitHub exposes every PR's head on the base repo as refs/pull//head, which the App path already uses. Extend that to the merge strategy: when merging a GitHub PR, fetch pull//head from origin instead of the fork's remote. This lets fork PRs run in merge mode without access to the fork. It is a no-op for same-repo PRs (same commit), and unchanged for the branch strategy and non-GitHub hosts.
This is what is needed to support forks in our environments. We run a controller app that issues scoped tokens from a single GitHub app to many hundreds of Atlantis instances. It is using app token, but the Atlantis instance isn't configured to run as an app. This token issuing process allows us to scale the provisioning of Atlantis instances in our org.