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

Automate the backports on PR merge to main #27450

Open
wants to merge 1 commit into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/backport-dispatch.yaml
@@ -0,0 +1,34 @@
name: Automated Backporting via Dispatch

on:
workflow_dispatch:
inputs:
targetBranch:
description: 'Release (22.0, 24.0, ...)'
required: true
type: string
default: "24.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a default at all? This is likely to get quickly out of date. Also, can we provide a default if this value is already required?

pullRequest:
description: 'Pull request (just the ID)'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be number, PRs have both a number (28087) and an ID (PR_kwDOAKnDVc5qMnnG)

Suggested change
description: 'Pull request (just the ID)'
description: 'Pull request number'

required: true
type: string
dryRun:
description: 'Dry run'
required: false
default: false
type: boolean

jobs:
backporting:
name: "Backporting"
runs-on: ubuntu-latest
steps:
- name: Backporting
uses: kiegroup/git-backporting@bce5dd4f9969d47da9cbb6ed06abbf87216afc98 # 4.5.1
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, should we not be using the existing backport script here directly? If we're going to use an action going forward I'd argue it should be the only way to do a backport to avoid inconsistencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I would just use the script and not an action, as I find it easy and quick to do that, but if others prefer a action then I don't see a big deal with having both. Good point about using the same approach both places thouyy

with:
target-branch: release/${{ inputs.targetBranch }}
pull-request: https://github.com/${{ github.repository }}/pulls/${{ inputs.pullRequest }}
auth: ${{ secrets.GITHUB_TOKEN }}
dry-run: ${{ inputs.dryRun }}
bp-branch-name: backport/${{ inputs.targetBranch }}/pr-${{ inputs.pullRequest }}
no-squash: true
22 changes: 22 additions & 0 deletions .github/workflows/backport-reaper.yaml
@@ -0,0 +1,22 @@
name: Backport branch reaper

on:
pull_request_target:
types:
- closed
branches:
- 'release/*.*'

jobs:
remove_backport_branch:
if: startsWith(github.event.pull_request.head.ref, 'backport/') && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Delete PR head branches
# language=bash
run: |
# safety switch that we only remove backport branches
BP=$(echo ${{ github.event.pull_request.head.ref }} | sed 's|backport/||' )
jonkoops marked this conversation as resolved.
Show resolved Hide resolved
gh api --method DELETE /repos/${{ github.event.pull_request.base.repo.full_name }}/git/refs/heads/backport/${BP}
env:
GH_TOKEN: ${{ github.token }}
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- main
- dependabot/**
- backport/**
jonkoops marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
workflow_dispatch:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- main
- dependabot/**
- backport/**
- quarkus-next
pull_request:
branches: [main]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/documentation.yml
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- main
- dependabot/**
- backport/**
- quarkus-next
pull_request:
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/guides.yml
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- main
- dependabot/**
- backport/**
- quarkus-next
pull_request:
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/js-ci.yml
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- main
- dependabot/**
- backport/**
- quarkus-next
pull_request:
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/operator-ci.yml
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- main
- dependabot/**
- backport/**
pull_request:
workflow_dispatch:

Expand Down