Skip to content

Trigger backport PR job on merge, not just label-added - #3292

Open
gabedos wants to merge 2 commits into
mainfrom
gabedos/backport-label-before-merge
Open

Trigger backport PR job on merge, not just label-added#3292
gabedos wants to merge 2 commits into
mainfrom
gabedos/backport-label-before-merge

Conversation

@gabedos

@gabedos gabedos commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adjusts .github/workflows/backport-pr.yml so a backport label applied before a PR is merged still results in a backport PR being created.

  • Adds closed alongside labeled to the pull_request trigger types.
  • Gates the job's if on github.event.pull_request.merged, accepting either a closed event or a labeled event carrying a backport/* label.

Motivation

Today the job only runs on the labeled event. If a maintainer adds a backport/* label before the PR merges, the job fires immediately, but tibdex/backport requires the PR to already be merged and fails. Nothing re-triggers it once the merge actually happens, so the backport silently never gets created unless someone re-adds the label after merge.

Aligns the Operator backport process with the Agent backport process to avoid confusion for developers.

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed (see: signing commits)

Previously the backport workflow only ran on the pull_request `labeled`
event, so adding a `backport/*` label before a PR merged caused the job
to fail (tibdex/backport requires a merged PR) with no retry once the
merge actually happened. Add `closed` as a trigger type and gate the
job on `pull_request.merged` so a pre-existing backport label is picked
up at merge time as well.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 21, 2026

Copy link
Copy Markdown

Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 47.95% (+0.99%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6d6e3a6 | Docs | Datadog PR Page | Give us feedback!

@gabedos
gabedos marked this pull request as ready for review July 22, 2026 12:49
@gabedos
gabedos requested a review from a team July 22, 2026 12:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f749d169ce

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if: >
(github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged &&
(github.event.action == 'closed' ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate closed events on backport labels

When any merged PR is closed without a backport/* label but has a milestone, this new closed branch now runs the whole job. tibdex/backport no-ops and sets created_pull_requests to {} when no labels match, but the following github-script step still parses that output, gets undefined from Object.values(backportData)[0], and calls issues.update without an issue_number, so ordinary merged PRs with milestones will leave the Backport PR workflow failing. Please either require a matching backport label on the closed path or skip the milestone-copy step when no PR was created.

Useful? React with 👍 / 👎.

tibdex/backport no-ops on merged PRs without a matching backport
label, leaving created_pull_requests empty. The milestone-copy step
would then call issues.update with an undefined issue number and
fail the job.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant