For example, if a PR is created from a branch that based on main
, and a new commit to main
after branching changes docs, then the PR docs build will show that the PR changes the docs, even though that is not the case. In fact, the docs in main
are ahead of what's in the PR, and ideally the PR's branch would be rebased, however it is not always necessary to rebase a branch when there are otherwise no conflicts.
The reason this happens is that in the PR workflow, we build the docs for both the BASE and HEAD commit of the PR. If the PR is against main
for example, we build docs for main
, but since the PR is based on an earlier main
commit, the output will be different.
One thing we can try to do, is do our BASE build against the commit that the PR branch was started from. That would solve the situation laid out above.
But in another case, consider that the PR actually did change docs, but main
is now ahead of the branch with its on changes. If we build against the PR branch's original base, we will showing the (intended) changes of the PR, but will not necessarily be representing the sate of the docs after the PR is merged.
Although GitHub will alert to conflicts in the tracked files, the rendered docsite is not tracked.
I'm not sure what the best or correct course of action is.
I don't think it's a good idea to do 3 builds, comparing the PR to both its own base and to its merge target, it seems a little too complicated.
A third option, whether the base render is based on latest target or on branch's base, is to detect that the branch has drifted, and include a warning in the PR comment that the differences shown may not be accurate, recommending a rebase if accuracy is a concern.