|
| 1 | +--- |
| 2 | +navigation_title: Choose a branching strategy |
| 3 | +--- |
| 4 | + |
| 5 | +# Choose the docs branching strategy for a repository |
| 6 | + |
| 7 | +With Docs V3 (elastic.co/docs), a single branch is published per repository. This branch is set to `main` by default. This is known as the continuous deployment branching strategy. However, it is possible to instead publish a different branch, also known as the tagged branching strategy. |
| 8 | + |
| 9 | +On this page, you'll learn how to choose the right branching strategy for your repository, and how to change the branching strategy. You'll also learn about the workflows for working with each branching strategy. |
| 10 | + |
| 11 | +## Why is `main` the default publication branch? |
| 12 | + |
| 13 | +The main reasons for this choice are: |
| 14 | + |
| 15 | +* With Docs V3, there is no longer a different version of each page for each minor release. Instead, the same page [covers all versions](cumulative-docs.md), and any changes are indicated throughout the content. |
| 16 | +* More and more products are released from `main` branches, making these branches the most up to date at any given time. This is especially true for {{serverless-full}} and {{ecloud}}. |
| 17 | + |
| 18 | + |
| 19 | +## Why would we want to publish a different branch instead? |
| 20 | + |
| 21 | +Publishing from the main branch isn’t the best option for all repositories. |
| 22 | + |
| 23 | +* `main` can contain code and docs for unreleased versions that we don’t want to publish yet. |
| 24 | +* The versioning scheme and release cadence of the product associated with a repository can vary, and it can be inconsistent to have the docs associated with a certain version live in a different branch than the code. |
| 25 | + |
| 26 | +If you choose this publication model for your repository AND that repository includes {{serverless-short}} or {{ecloud}} documentation, you will need to make sure that {{serverless-short}}- and {{ecloud}}-related changes are also backported to the branch that is publishing to the public docs site. |
| 27 | + |
| 28 | +You **don't** need to change your branching strategy to enable writing docs about future versions. Review the [continuous deployment workflow](#workflow-1-default-continuous-deployment) and [](cumulative-docs.md) to learn more. |
| 29 | + |
| 30 | +Note that regardless of the publication branch that is set, the documentation must still flag all changes introduced so far since the last major release. This is NOT an alternative to [writing docs cumulatively](cumulative-docs.md). |
| 31 | + |
| 32 | +## How to change the published branch |
| 33 | + |
| 34 | +Choosing to switch between publishing docs from `main` and publishing docs from a version branch is a long-term decision. This decision impacts all docs for an entire repository. Reach out to the docs team to discuss the change. |
| 35 | + |
| 36 | +For more information, refer to [](/configure/content-sources.md). |
| 37 | + |
| 38 | +After it has been established that a repository should publish from a version branch rather than `main`: |
| 39 | + |
| 40 | +1. [Add new triggers to the `docs-build` CI integration](/configure/content-sources.md#ci-configuration). Merge these changes to `main` or `master` and the intended version branches. |
| 41 | +2. Open a PR to trigger the CI integration and confirm that the docs build. |
| 42 | +3. Open a PR updating the [docs assembler file](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml): |
| 43 | + * Specify which is the `current` branch for the repository. This branch is the branch from which docs are deployed to production at [elastic.co/docs](http://elastic.co/docs). |
| 44 | + * Specify which is the `next` branch for the repository. The branch defined as `next` publishes docs internally to [staging-website.elastic.co/docs](http://staging-website.elastic.co/docs) |
| 45 | + * Setting this branch to the next version branch in line is a good practice to preview docs change for an upcoming version. |
| 46 | + * Otherwise, keeping it set to `main` is also an option since this is where the content is initially developed and merged. This is the default. |
| 47 | +4. In the assembler PR, add the `ci` label. After CI runs, confirm that the intended version branches are publishing to the link service. When links are being published as intended, they can be found at the following URL, where `repo` is your repo name and `branch` is your newly configured branch: |
| 48 | + |
| 49 | + ```text |
| 50 | + elastic-docs-link-index.s3.us-east-2.amazonaws.com/elastic/<repo>/<branch>/links.json |
| 51 | + ``` |
| 52 | +5. Rerun the `validate-assembler` check on the PR. |
| 53 | +6. After checks pass and the docs engineering team approves, you can merge the PR. |
| 54 | + |
| 55 | +After these steps are completed, the docs engineering team needs to release a new version of our build tool to complete the process. This process will be decoupled in a future release. After a new version is released, the switch is complete and the production documentation reflects the specified current branch. |
| 56 | + |
| 57 | +### Update the release process |
| 58 | + |
| 59 | +When you publish from specific version branches, you need to bump the version branch as part of the release process. |
| 60 | + |
| 61 | +Add an action as part of that repo’s release process for the release manager to update this same assembler file and bump the `current` branch with each release, as appropriate. The `next` branch also needs to be bumped if it is not set to `main`. |
| 62 | + |
| 63 | +When these releases happen, create a PR against the [assembler file](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml) that defines the new `current` branch, to merge on release day. |
| 64 | + |
| 65 | +:::{tip} |
| 66 | +Regardless of the branching strategy, you also need to update the current version in [versions.yml](https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/versions.yml) as part of your release process. This version number is used in documentation variables and drives our [dynamic version badge logic](/contribute/cumulative-docs.md#how-do-these-tags-behave-in-the-output). |
| 67 | +::: |
| 68 | + |
| 69 | + |
| 70 | +## Workflow 1 (default): Continuous deployment |
| 71 | + |
| 72 | +Learn how to make updates in the continuous deployment branching strategy, where the repo is publishing docs from `main`. |
| 73 | + |
| 74 | +### Where to make docs changes [make-changes-cd] |
| 75 | + |
| 76 | +Initiate the changes by opening a PR against the `main` branch of the repo. |
| 77 | + |
| 78 | +### How to write those changes [write-changes-cd] |
| 79 | + |
| 80 | +In elastic.co/docs (Docs V3), we [write docs cumulatively](cumulative-docs.md) regardless of the branching strategy selected. |
| 81 | + |
| 82 | +### Merging and backporting [merge-backport-cd] |
| 83 | + |
| 84 | +When a repo publishes docs from its `main` branch, any merged changes are published within 30 minutes. It is then very important to consider the timing of the merge depending on the documented product: |
| 85 | + |
| 86 | +| | Case | Approach | |
| 87 | +| --- | --- | --- | |
| 88 | +| 1 | You are documenting changes for an unversioned product (typically Serverless or Elastic Cloud), and the changes should only go live when the corresponding code or feature is available to users. | The PR should be merged on or after the release date of the feature. | |
| 89 | +| 2 | You are documenting changes for a versioned product (any Stack components, ECE, ECK, etc.). | You have the choice between merging the PR as soon as it is approved, or merging it only on release day.<br><br>We have an automatic mechanism in place as part of the [cumulative docs strategy](cumulative-docs.md) that will show any changes published before its associated code or feature is available as `Planned`. | |
| 90 | +| 3 | You are documenting changes that apply to both versioned and unversioned products (typically a change that is being released for both Serverless and an upcoming Stack release). | The PR should only be merged on or after the release date of the feature in Serverless.<br><br>For versioned products, we have an automatic mechanism in place as part of the [cumulative docs strategy](cumulative-docs.md) that will show any changes published before its associated code or feature is available as `Planned`. | |
| 91 | + |
| 92 | +When a repo is publishing docs from its `main` branch, no backporting is needed. |
| 93 | + |
| 94 | +:::{tip} |
| 95 | +If you don’t want to hold on too many PRs to publish on release day, merge them to a feature branch, so you only have to merge this feature branch to `main` on release day. |
| 96 | +::: |
| 97 | + |
| 98 | +## Workflow 2: Tagged |
| 99 | + |
| 100 | +Learn how to make updates in the continuous deployment branching strategy, where the repo is publishing docs from a specific version branch. |
| 101 | + |
| 102 | +### Where to make docs changes [make-changes-td] |
| 103 | + |
| 104 | +Initiate the changes by opening a PR against the `main` branch of the repo, and backport the changes to the relevant version branches as detailed below. |
| 105 | + |
| 106 | +### How to write those changes [write-changes-td] |
| 107 | + |
| 108 | +In elastic.co/docs (Docs V3), we [write docs cumulatively](cumulative-docs.md) regardless of the branching strategy selected. |
| 109 | + |
| 110 | +### Merging and backporting [merge-backport-td] |
| 111 | + |
| 112 | +When a repo publishes docs from a version branch, there is no timing constraint to merge the initial PR against the `main` branch. If `main` is set as your `next` branch, then the docs changes become visible on the internal staging docs site at [staging-website.elastic.co/docs](http://staging-website.elastic.co/docs). Otherwise, the docs changes become visible on the internal staging docs site when you backport to your `next` branch. |
| 113 | + |
| 114 | +The changes must then be backported to their relevant version branches, and no further back than the branch set as `current` for the documentation publication system: |
| 115 | + |
| 116 | +| | Case | Approach | |
| 117 | +| --- | --- | --- | |
| 118 | +| 1 | You are documenting changes for an unversioned product (typically Serverless or Elastic Cloud), the changes should go live when the corresponding code or feature is available to users. | The PR should be backported to the docs `current` branch, and any intermediate version branches that already exist between `current` and `main`. Merge the backport PR for `current` only when you’re sure the corresponding feature is released. | |
| 119 | +| 2 | You are documenting changes for a versioned product (any Stack components, ECE, ECK, etc.). | Backport the PR to the relevant version branch and to any intermediate version branch that already exists. The changes will go live whenever these branches become the `current` docs branch.<br><br>We have an automatic mechanism in place as part of the [cumulative docs strategy](cumulative-docs.md) that will show any changes published before its associated code or feature is available as `Planned`. | |
| 120 | +| 3 | You are documenting changes that apply to both versioned and unversioned products (typically a change that is being released for both Serverless and an upcoming Stack release). | The PR should be backported to the docs `current` branch, and any intermediate version branches that already exist between `current` and `main`. Merge the backport PR for `current` only when you’re sure the corresponding feature is released. <br><br>For versioned products, we have an automatic mechanism in place as part of the [cumulative docs strategy](cumulative-docs.md) that will show any changes published before its associated code or feature is available as `Planned`. | |
| 121 | + |
| 122 | +#### Example [example-td] |
| 123 | + |
| 124 | +For example, in a situation where 9.0, 9.1, and 9.2 are already released, and the 9.3 branch has already been cut: |
| 125 | + |
| 126 | +* The branch set as `current` in the [docs assembler](https://github.com/elastic/docs-builder/blob/625e75b35841be938a8df76a62deeee811ba52d4/src/tooling/docs-assembler/assembler.yml#L70) is 9.2. |
| 127 | +* The branch set as `next` (where the content development first happens), is `main`. |
| 128 | +* 9.4 changes are only done on the `main` branch. |
| 129 | +* 9.3 changes are done on the `main` branch and backported to the 9.3 branch. |
| 130 | +* 9.1 changes are done on the `main` branch and backported to the 9.3 and 9.2 branches. Since 9.2 is the current docs branch, no need to go further. |
| 131 | +* Serverless changes are done on the `main` branch. They are backported to the `current` docs branch and any intermediate branches. In this case: 9.3 and 9.2. |
| 132 | +* Changes not specific to a version are done on the `main` branch and backported to all branches down to the `current` docs branch. In this case: 9.3 and 9.2. |
| 133 | + |
| 134 | +:::{note} |
| 135 | +While you *can* backport to versions prior to the `current` version when applicable to maintain parity between the code and the docs on a given branch, that content will not be used in the current state of the docs. |
| 136 | +::: |
0 commit comments