Skip to content

Commit

Permalink
feat: add basic initial backport
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Clucas <alan@clucas.org>
  • Loading branch information
Joibel committed Feb 4, 2025
1 parent dea9d0f commit 0d895b4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/backport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Backport merged pull request
on:
pull_request_target:
types: [closed]
issue_comment:
types: [created]
permissions:
contents: write # so it can comment
pull-requests: write # so it can create pull requests
jobs:
backport:
name: Backport pull request
runs-on: ubuntu-latest

# Only run when pull request is merged
# or when a comment starting with `/backport` is created by someone other than the
# https://github.com/backport-action bot user (user id: 97796249). Note that if you use your
# own PAT as `github_token`, that you should replace this id with yours.
if: >
(
github.event_name == 'pull_request_target' &&
github.event.pull_request.merged
) || (
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.comment.user.id != 97796249 &&
startsWith(github.event.comment.body, '/backport')
)
steps:
- uses: actions/checkout@v4
- name: Create backport pull requests
uses: korthout/backport-action@be567af183754f6a5d831ae90f648954763f17f5 # v3.1.0
with:
label_pattern: ^backport/([^ ]+)$
pull_title: ${pull_title} [Backport ${target_branch}]
pull_description: |-
Automated backport of #${pull_number} to `${target_branch}`
Associated issues if any: [${issue_refs}]
* [ ] Good to test
conflict_resolution: draft_commit_conflicts
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- "main"
- "release-*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
- release/*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ args
async
auth
backend
backport
backported
backporting
boolean
booleans
buildkit
Expand Down
15 changes: 15 additions & 0 deletions docs/releasing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Release Instructions

## Backporting fixes

Fixes can be backported using the automated cherry-picker.
This will only work on merged commits, and always chooses the branches to backport based on labels.
Label of the form `backport/<targetbranch>` will cherry-pick this commit to the given branch - e.g. `backport/release-3.6`.

The backport will be triggered on merging, or on by adding a comment starting with `/backport` - any extra text is ignored by the bot.
You cannot specify the backport target using comment text, only a label.

Backported commits can be backported, so it may make sense to backport the `release-3.6` backport to `release-3.5` for example.

Backported fixes may fail on merge conflicts and assistance will be given by the bot on how to manually create a backport.

Commits generated this way are merged in the normal way, this part is not automated.

## Cherry-Picking Fixes

✋ Before you start, make sure you have created a release branch (e.g. `release-3.3`) and it's passing CI.
Expand Down

0 comments on commit 0d895b4

Please sign in to comment.