Skip to content

Commit

Permalink
Automate backports via a dispatch workflow
Browse files Browse the repository at this point in the history
Closes #27449

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
  • Loading branch information
ahus1 committed Mar 15, 2024
1 parent 77c4cee commit ef9d429
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
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"
pullRequest:
description: 'Pull request (just the ID)'
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
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/||' )
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/**
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

0 comments on commit ef9d429

Please sign in to comment.