From 2416ea1e543372ace9d9c9cf189d3c7fbf4e5ac2 Mon Sep 17 00:00:00 2001 From: mvlassis Date: Tue, 1 Sep 2026 12:14:38 +0300 Subject: [PATCH] feat: Add support for backport automation --- .github/automatic_backport_tracks.yaml | 2 ++ .github/workflows/on_pull_request.yaml | 18 +++++++++++++++ .github/workflows/on_pull_request_closed.yaml | 23 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .github/automatic_backport_tracks.yaml create mode 100644 .github/workflows/on_pull_request.yaml create mode 100644 .github/workflows/on_pull_request_closed.yaml diff --git a/.github/automatic_backport_tracks.yaml b/.github/automatic_backport_tracks.yaml new file mode 100644 index 0000000..14a351b --- /dev/null +++ b/.github/automatic_backport_tracks.yaml @@ -0,0 +1,2 @@ +automatic_backport_tracks: + - track/1.0 diff --git a/.github/workflows/on_pull_request.yaml b/.github/workflows/on_pull_request.yaml new file mode 100644 index 0000000..e61df83 --- /dev/null +++ b/.github/workflows/on_pull_request.yaml @@ -0,0 +1,18 @@ +name: On Pull Request + +# On pull_request, we: +# * create backport labels if it is against main, only when the PR is opened/reopened + +on: + pull_request: + +jobs: + + populate-labels: + name: Populate labels + if: github.base_ref == 'main' && (github.event.action == 'opened' || github.event.action == 'reopened') + uses: canonical/charmed-kubeflow-workflows/.github/workflows/populate-labels.yaml@main + secrets: inherit + with: + track_file_path: ".github/automatic_backport_tracks.yaml" + label_prefix: "backport " diff --git a/.github/workflows/on_pull_request_closed.yaml b/.github/workflows/on_pull_request_closed.yaml new file mode 100644 index 0000000..bf4c1de --- /dev/null +++ b/.github/workflows/on_pull_request_closed.yaml @@ -0,0 +1,23 @@ +name: On Pull Request Closed + +# When a pull request is pushed on the main branch, automatically +# create backport PRs according to the labels on the pull request. +# If there are conflicts, create a PR but leave it as draft. + +on: + pull_request_target: + types: [closed] + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + + backport: + name: Backport pull request + if: github.event.pull_request.merged + uses: canonical/charmed-kubeflow-workflows/.github/workflows/backport-pr.yaml@main + secrets: inherit