Skip to content

[ML] Add automatic backport GitHub Action#2921

Merged
edsavage merged 1 commit intoelastic:mainfrom
edsavage:auto-backport
Feb 26, 2026
Merged

[ML] Add automatic backport GitHub Action#2921
edsavage merged 1 commit intoelastic:mainfrom
edsavage:auto-backport

Conversation

@edsavage
Copy link
Contributor

Summary

  • Adds a GitHub Actions workflow (.github/workflows/backport.yml) that automatically creates backport PRs when a merged PR has version labels (e.g. v9.3.0)
  • Uses sorenlouv/backport-github-action@v10.2.0 which reads the existing .backportrc.json configuration
  • Updates .backportrc.json: fixes stale branchLabelMapping (v8.17.0 -> v9.4.0 for main) and adds current release branches (9.1, 9.2, 9.3) to targetBranchChoices

How it works

  1. Add version label(s) to a PR (e.g. v9.3.0 to backport to branch 9.3)
  2. When the PR merges, the GitHub Action triggers and cherry-picks the commits
  3. A backport PR is automatically created targeting the mapped branch
  4. Backport PRs receive the backport label (preventing recursive backport loops)

All required version labels already exist on the repo (v9.4.0, v9.3.0, v9.2.0, etc.).

Notes

  • The workflow uses GITHUB_TOKEN (default GitHub Actions token). If backport PRs need to trigger CI workflows automatically, a bot PAT (e.g. elasticmachine) may be needed as a follow-up, since GITHUB_TOKEN-created events don't trigger other workflows.
  • The pull_request_target trigger ensures the workflow runs in the context of the base repository.

Test plan

  • Merge a test PR with a version label (e.g. v9.3.0) and verify a backport PR is created automatically
  • Verify backport PRs receive the backport label
  • Verify PRs without version labels don't trigger unnecessary action runs
  • Verify backport PRs themselves don't trigger recursive backports

Made with Cursor

@prodsecmachine
Copy link

prodsecmachine commented Feb 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Add a GitHub Actions workflow that automatically creates backport PRs
when a merged PR has version labels. Uses sorenlouv/backport-github-action
with an ephemeral token from Vault (via elastic/ci-gh-actions/fetch-github-token)
so that backport PRs trigger CI workflows.

Also updates .backportrc.json to fix the stale branchLabelMapping
(v9.4.0 -> main) and add current release branches to targetBranchChoices.

Workflow:
1. Add version label(s) to a PR (e.g. v9.3.0 for branch 9.3)
2. When the PR merges, the action cherry-picks and opens a backport PR
3. Backport PRs get the 'backport' label (preventing recursive backports)
4. CI runs on backport PRs since they're created with the bot token

Made-with: Cursor
@edsavage edsavage merged commit f14126a into elastic:main Feb 26, 2026
4 of 11 checks passed
@edsavage edsavage deleted the auto-backport branch February 26, 2026 01:07
edsavage added a commit to edsavage/ml-cpp that referenced this pull request Feb 26, 2026
Add a GitHub Actions workflow that automatically creates backport PRs
when a merged PR has version labels. Uses sorenlouv/backport-github-action
with an ephemeral token from Vault (via elastic/ci-gh-actions/fetch-github-token)
so that backport PRs trigger CI workflows.

Also updates .backportrc.json to fix the stale branchLabelMapping
(v9.4.0 -> main) and add current release branches to targetBranchChoices.

Workflow:
1. Add version label(s) to a PR (e.g. v9.3.0 for branch 9.3)
2. When the PR merges, the action cherry-picks and opens a backport PR
3. Backport PRs get the 'backport' label (preventing recursive backports)
4. CI runs on backport PRs since they're created with the bot token

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants