diff --git a/.backportrc.json b/.backportrc.json new file mode 100644 index 000000000..4aec607ea --- /dev/null +++ b/.backportrc.json @@ -0,0 +1,5 @@ +{ + "repoOwner": "Neo4j", + "repoName": "docs-cypher", + "prTitle": "[Cherry-pick][{{targetBranch}}] {{commitMessages}}" +} \ No newline at end of file diff --git a/.github/workflows/auto-backport.yml b/.github/workflows/auto-backport.yml new file mode 100644 index 000000000..1a1264647 --- /dev/null +++ b/.github/workflows/auto-backport.yml @@ -0,0 +1,31 @@ +name: auto-cherry-pick +on: + pull_request_target: + types: ["labeled", "closed"] + +jobs: + backport: + name: Cherry-pick PR + runs-on: [ubuntu-latest] + if: | + github.event.pull_request.merged == true + && contains(github.event.pull_request.labels.*.name, 'auto-cherry-pick') + && ( + (github.event.action == 'labeled' && github.event.label.name == 'auto-cherry-pick') + || (github.event.action == 'closed') + ) + steps: + - name: Cherry-pick action + uses: sorenlouv/backport-github-action@929f69d04adbc196d982e60f02837b6cc00b3129 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + auto_backport_label_prefix: auto-cherry-pick-to- + add_original_reviewers: true + + - name: Info log + if: ${{ success() }} + run: cat ~/.backport/backport.info.log + + - name: Debug log + if: ${{ failure() }} + run: cat ~/.backport/backport.debug.log \ No newline at end of file diff --git a/README.adoc b/README.adoc index 71281a24f..1a34d9da1 100644 --- a/README.adoc +++ b/README.adoc @@ -68,3 +68,33 @@ There are a few edge cases where we might want to work only on the current branc ** Create a feature branch from `dev`, to be merged into `dev` when appropriate. * When a new version is ready to published, the `5.x` branch will get a git tag, named with the exact version (for example, **5.1.0**), signifying that this point-in-time marks the completion of the work for that minor release. * Updates merged into the `dev` branch for the next release are cherry-picked into the `5.x` branch. + + +=== Enable automatic cherry-picking on a PR + +To enable automatic cherry-picking on a PR, add the label `auto-cherry-pick` to it. +Without it, the responsible GitHub action is not going to be triggered. + +To select the target branches you would like to cherry-pick your PR to, add labels of the following structure: `auto-cherry-pick-to-`. +For example: `auto-cherry-pick-to-cypher-25` to cherry-pick it to the branch `cypher-25` or `auto-cherry-pick-to-5.x` for the branch `5.x`. +You may even add new labels for branches that do not have such a label yet. + +The feature is triggered by either merging a PR with the `auto-cherry-pick` label or by adding the `auto-cherry-pick` label to an already closed and merged PR. +In the latter case, ensure that you first add the labels containing the target branches and then finally the `auto-cherry-pick` label. +Otherwise the automation starts without any target branches. + + +==== Details + +The PRs created by this GitHub action will have their heading prefixed with `[Cherry-pick][]`. +So, for example, for `6.x` as the target branch and `some changes` as the original PR heading, it results in `[Cherry-pick][6.x] some changes` as the heading for the cherry-picked PR. +In case an assignee was set for the original PR, the cherry-picked PRs will also receive the same assignee. +You must add reviewers manually after the cherry-picked PRs have been created. + +The creation of cherry-picked PRs can take a few minutes. +If you are an assignee of the original PR, you receive an email notification once the cherry-picked PRs have been created. +The original PR is updated with a comment that contains links to the newly created cherry-picked PRs. + +In case of a merge conflict while cherry-picking to a specific release branch, the branch will be skipped. Information on skipped branches is also included in the comment added to the original PR. +In that case you will have to take care of cherry-picking manually and resolve the conflicts. +This is not going to influence the other release branches as long as they do not have conflicts.