Skip to content

[ML] Add auto-backport label for automatic backport PR merging#2947

Merged
edsavage merged 1 commit intoelastic:mainfrom
edsavage:auto-backport-label
Mar 8, 2026
Merged

[ML] Add auto-backport label for automatic backport PR merging#2947
edsavage merged 1 commit intoelastic:mainfrom
edsavage:auto-backport-label

Conversation

@edsavage
Copy link
Contributor

@edsavage edsavage commented Mar 8, 2026

Summary

Adds an auto-backport label that controls whether backport PRs are automatically merged after CI passes. This builds on PR #2940 (label copying and backport-pending tracking).

How it works

Without auto-backport label (default): Backport PRs are created as before, requiring manual review and merge.

With auto-backport label on the original PR:

  1. Backport PRs are created normally by sorenlouv/backport-github-action
  2. The Enable auto-merge on backport PRs step parses the created PR numbers from the backport log and enables GitHub auto-merge (squash) on each one
  3. The new auto-approve-backports.yml workflow auto-approves backport PRs that:
    • Are opened by github-actions[bot]
    • Have a branch name starting with backport/
    • Originate from a source PR that has the auto-backport label
  4. Once CI passes and the approval is in place, GitHub auto-merges the backport PR
  5. When all backport PRs are merged, the backport-pending label is removed from the original PR (from PR [ML] Improve backport automation with label copying and pending tracking #2940)

Prerequisites

Auto-merge must be enabled in the repo settings (Settings > General > Allow auto-merge). Currently it is disabled (allow_auto_merge: false). A repo admin needs to toggle this on. Without it, the gh pr merge --auto step will emit a warning but not fail the workflow.

Label

Created the auto-backport label on the repo (color #692F45, matching elasticsearch's label).

Comparison with other elastic repos

Repo Approach
Kibana autoMerge: true in .backportrc.json + auto-approve-backports.yml
Connectors auto-backport label triggers auto-merge via workflow inputs
Elasticsearch auto-backport label exists but backport handled by external infra
ml-cpp (this PR) auto-backport label on original PR → auto-merge + auto-approve on backport PRs

Test plan

Note: requires a repo admin to enable auto-merge first.

  • Merge a PR without auto-backport — verify backport PRs are created but NOT auto-merged
  • Merge a PR with auto-backport — verify backport PRs get auto-merge enabled and auto-approved
  • Verify backport PRs auto-merge after CI passes
  • Verify backport-pending is removed from the original PR after all backports merge

Made with Cursor

When the original PR has the 'auto-backport' label:
- The backport workflow enables GitHub auto-merge (squash) on the
  created backport PRs after they are created.
- A new auto-approve-backports workflow auto-approves backport PRs
  opened by github-actions[bot] on version branches, satisfying
  the branch protection requirement for 1 approval.

Without the 'auto-backport' label, backport PRs are created as
before but require manual review and merge.

Prerequisites: auto-merge must be enabled in the repo settings
(Settings > General > Allow auto-merge).

Made-with: Cursor
@prodsecmachine
Copy link

prodsecmachine commented Mar 8, 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.

@edsavage edsavage merged commit 55edb9c into elastic:main Mar 8, 2026
4 of 16 checks passed
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