From 8ddf0354cffc1caae031cabe19566015bacf10c7 Mon Sep 17 00:00:00 2001 From: Richard Sill Date: Mon, 21 Oct 2024 14:51:02 +0200 Subject: [PATCH 1/3] auto-cherry-pick for docs-cypher --- .backportrc.json | 5 +++++ .github/workflows/auto-backport.yml | 31 ++++++++++++++++++++++++++++ README.adoc | 32 ++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .backportrc.json create mode 100644 .github/workflows/auto-backport.yml 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..4ac3be086 100644 --- a/README.adoc +++ b/README.adoc @@ -21,7 +21,7 @@ npm i To convert asciidoc source to HTML: ---- -npm run build +npm run build ---- @@ -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. From 27f16119bcc2af9dc9918d8359c652eeecdf9548 Mon Sep 17 00:00:00 2001 From: Richard Sill Date: Mon, 21 Oct 2024 14:51:57 +0200 Subject: [PATCH 2/3] erroneous whitespace --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 4ac3be086..1a34d9da1 100644 --- a/README.adoc +++ b/README.adoc @@ -21,7 +21,7 @@ npm i To convert asciidoc source to HTML: ---- -npm run build +npm run build ---- From 778363210179f424e406b0b90f7d14f4d746edca Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Thu, 15 May 2025 18:29:42 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Richard Sill <156673635+rsill-neo4j@users.noreply.github.com> --- .github/workflows/auto-backport.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/auto-backport.yml b/.github/workflows/auto-backport.yml index 1a1264647..b5a6031ab 100644 --- a/.github/workflows/auto-backport.yml +++ b/.github/workflows/auto-backport.yml @@ -1,7 +1,7 @@ name: auto-cherry-pick on: pull_request_target: - types: ["labeled", "closed"] + types: ["closed"] jobs: backport: @@ -9,18 +9,16 @@ jobs: 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') + && contains(github.event.pull_request.labels.*.name, '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 + auto_backport_label_prefix: cherry-pick-to- + add_original_reviewers: false - name: Info log if: ${{ success() }}