Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-cherry-pick for docs-cypher #1073

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .backportrc.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file? I think it's needed only when using the cli tool, which we are not using.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm... the prTitle i think shows up on the auto-generated PRs 🤔

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"repoOwner": "Neo4j",
"repoName": "docs-cypher",
"prTitle": "[Cherry-pick][{{targetBranch}}] {{commitMessages}}"
}
31 changes: 31 additions & 0 deletions .github/workflows/auto-backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: auto-cherry-pick
on:
pull_request_target:
types: ["labeled", "closed"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
types: ["labeled", "closed"]
types: ["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')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&& contains(github.event.pull_request.labels.*.name, 'auto-cherry-pick')
&& contains(github.event.pull_request.labels.*.name, 'cherry-pick')

&& (
(github.event.action == 'labeled' && github.event.label.name == 'auto-cherry-pick')
|| (github.event.action == 'closed')
Comment on lines +13 to +15
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&& (
(github.event.action == 'labeled' && github.event.label.name == 'auto-cherry-pick')
|| (github.event.action == 'closed')
&& 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-
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto_backport_label_prefix: auto-cherry-pick-to-
auto_backport_label_prefix: cherry-pick-to-

add_original_reviewers: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_original_reviewers: true
add_original_reviewers: false


- name: Info log
if: ${{ success() }}
run: cat ~/.backport/backport.info.log

- name: Debug log
if: ${{ failure() }}
run: cat ~/.backport/backport.debug.log
30 changes: 30 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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-<targetBranch>`.
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][<targetBranch>]`.
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.