Skip to content

feat: fetch fork PR head from base repo in the merge checkout strategy - #6743

Open
meringu wants to merge 1 commit into
runatlantis:mainfrom
meringu:fork-fetch-via-base-on-merge
Open

feat: fetch fork PR head from base repo in the merge checkout strategy#6743
meringu wants to merge 1 commit into
runatlantis:mainfrom
meringu:fork-fetch-via-base-on-merge

Conversation

@meringu

@meringu meringu commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

@dosubot dosubot Bot added feature New functionality/enhancement go Pull requests that update Go code provider/github labels Aug 6, 2026
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
meringu force-pushed the fork-fetch-via-base-on-merge branch from 5dc1e75 to 1d55aaa Compare August 7, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality/enhancement go Pull requests that update Go code provider/github

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant