|
| 1 | +Branch Protection and Bot Commits |
| 2 | +================================= |
| 3 | + |
| 4 | +Fast Forward repositories keep generated documentation out of protected |
| 5 | +branches until the related pull request is merged. This keeps ``main`` stable, |
| 6 | +lets maintainers review generated output before it becomes canonical, and |
| 7 | +avoids requiring automation to bypass branch protection for normal preview |
| 8 | +updates. |
| 9 | + |
| 10 | +The model has two publishing lanes: |
| 11 | + |
| 12 | +- pull requests publish isolated previews; |
| 13 | +- merges into ``main`` publish the final wiki and reports. |
| 14 | + |
| 15 | +Wiki Preview Lifecycle |
| 16 | +---------------------- |
| 17 | + |
| 18 | +The wiki workflow writes generated Markdown to the GitHub wiki repository, but |
| 19 | +it does not publish pull request content directly to the wiki ``master`` branch. |
| 20 | +Instead, each pull request receives a dedicated wiki branch. |
| 21 | + |
| 22 | +For pull request ``123`` the workflow: |
| 23 | + |
| 24 | +1. runs ``composer dev-tools wiki -- --target=.github/wiki``; |
| 25 | +2. commits the generated wiki content to the wiki branch ``pr-123``; |
| 26 | +3. updates the parent repository submodule pointer at ``.github/wiki``; |
| 27 | +4. commits that pointer update back to the pull request branch. |
| 28 | + |
| 29 | +The parent repository commit is important because reviewers can see exactly |
| 30 | +which generated wiki revision belongs to the pull request. The bot commit SHOULD |
| 31 | +stay on the pull request branch because protected ``main`` branches usually |
| 32 | +reject direct commits. |
| 33 | + |
| 34 | +After the pull request is merged into ``main``, the publish job copies the |
| 35 | +content from the wiki preview branch, such as ``pr-123``, to the wiki |
| 36 | +``master`` branch. That makes the reviewed wiki content live only after the |
| 37 | +source code merge is complete. |
| 38 | + |
| 39 | +Reports Preview Lifecycle |
| 40 | +------------------------- |
| 41 | + |
| 42 | +Reports use the same review-before-publish idea, but the output is served from |
| 43 | +GitHub Pages instead of the wiki repository. |
| 44 | + |
| 45 | +On pull requests, the reports workflow: |
| 46 | + |
| 47 | +- generates docs, coverage, and report assets from the pull request code; |
| 48 | +- publishes them under ``previews/pr-<number>/`` in the Pages branch; |
| 49 | +- comments on the pull request with preview links when possible; |
| 50 | +- keeps workflow artifacts available as a fallback when Pages publishing or the |
| 51 | + comment update is unavailable. |
| 52 | + |
| 53 | +On ``main``, the reports workflow publishes the final site at the root of the |
| 54 | +Pages branch. Pull request previews use PR-specific directories, so multiple |
| 55 | +open pull requests can have independent previews without overwriting each other. |
| 56 | + |
| 57 | +When a pull request is closed, the workflow SHOULD remove its preview directory. |
| 58 | +This prevents stale documentation and coverage reports from looking like active |
| 59 | +review artifacts. |
| 60 | + |
| 61 | +Branch Protection Interactions |
| 62 | +------------------------------ |
| 63 | + |
| 64 | +Protected branches usually block direct pushes, require status checks, and may |
| 65 | +require signed commits or linear history. The preview workflows are designed to |
| 66 | +respect those rules: |
| 67 | + |
| 68 | +- bot commits update the pull request branch, not ``main``; |
| 69 | +- final wiki publication runs after the merge into ``main``; |
| 70 | +- final reports publication runs from the already-accepted ``main`` revision; |
| 71 | +- preview branches such as ``pr-123`` are temporary review targets. |
| 72 | + |
| 73 | +If a repository restricts bot pushes to pull request branches, maintainers |
| 74 | +should either allow the workflow token to update PR branches or require authors |
| 75 | +to refresh generated pointers manually. The preferred path is to allow bot |
| 76 | +updates on PR branches while keeping ``main`` protected. |
| 77 | + |
| 78 | +At a high level, the workflows need permission to read repository contents, |
| 79 | +write generated preview commits, update pull request comments, and publish Pages |
| 80 | +content. Keep those permissions scoped to the workflow jobs that actually need |
| 81 | +them. |
| 82 | + |
| 83 | +Resolving ``.github/wiki`` Pointer Conflicts |
| 84 | +-------------------------------------------- |
| 85 | + |
| 86 | +Submodule pointer conflicts happen when ``main`` and the pull request point to |
| 87 | +different generated wiki commits. Resolve them by rebasing the pull request and |
| 88 | +choosing the preview wiki commit that belongs to the pull request. |
| 89 | + |
| 90 | +For pull request ``123``: |
| 91 | + |
| 92 | +.. code-block:: bash |
| 93 | +
|
| 94 | + git fetch origin main |
| 95 | + git rebase origin/main |
| 96 | + git -C .github/wiki fetch origin master pr-123 |
| 97 | + git -C .github/wiki switch --detach origin/pr-123 |
| 98 | + git add .github/wiki |
| 99 | + git rebase --continue |
| 100 | + git push --force-with-lease |
| 101 | +
|
| 102 | +If the conflict appears after the preview job has already produced a newer bot |
| 103 | +commit, prefer the latest ``pr-123`` wiki commit. If the wiki branch no longer |
| 104 | +exists because the pull request was closed or merged, rerun the wiki workflow or |
| 105 | +regenerate the wiki locally before updating the pointer. |
| 106 | + |
| 107 | +Operational Checklist |
| 108 | +--------------------- |
| 109 | + |
| 110 | +- Keep source changes and generated pointer updates in the same pull request. |
| 111 | +- Review PR preview links before merging documentation-heavy changes. |
| 112 | +- Merge only through the protected ``main`` flow. |
| 113 | +- Let the post-merge wiki job publish to ``master``. |
| 114 | +- Let closed pull requests clean up their report preview directories. |
| 115 | + |
| 116 | +See :doc:`consumer-automation` for how reusable workflows and consumer stubs fit |
| 117 | +into this model, and :doc:`../usage/github-actions` for the workflow summary. |
0 commit comments