Skip to content

Github action to automatically create backport PR from merged PR's changes using labels - #1148

Merged
tdas merged 3 commits into
unitycatalog:mainfrom
tdas:backport-action
Nov 1, 2025
Merged

tdas merged 3 commits into
unitycatalog:mainfrom
tdas:backport-action

Conversation

@tdas

@tdas tdas commented Oct 31, 2025 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

As the title says. Specifically,

  • If you add a label "backport branch-0.3" to a PR, once the PR is merged, this github action will automatically create new PR with the merged + squashed changes on branch-0.3
  • if there is a merge conflict, then it will create a draft pull request with the first conflict encountered committed.

It uses this market place action - https://github.com/marketplace/actions/backport-merged-pull-requests-to-selected-branches#backport-action

Here is an example usage in a project that i coped - https://github.com/camunda/camunda/blob/main/.github/workflows/backport.yml

Signed-off-by: Tathagata Das <[email protected]>
Added custom token and updated label pattern for backporting.

Signed-off-by: Tathagata Das <[email protected]>
@tdas tdas changed the title Github action to backport merged PRs to previous branches Github action to automatically create backport PR from merged PR's changes using labels Oct 31, 2025
@tdas
tdas requested a review from openinx October 31, 2025 04:26

@openinx openinx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two minor comments, otherwise looks good to me !

Comment thread .github/workflows/backport.yml Outdated
with:
# Use custom token for backport operations
github_token: ${{ secrets.BACKPORT_ACTION_TOKEN }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: Just saw trailing whitespace in this line, could you please remove it, thanks ?

Image

runs-on: ubuntu-latest
name: Backport PR
# Only run if the PR was merged (not just closed)
if: github.event.pull_request.merged == true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to limit this application to main branch only to prevent triggering on already backported branches ?

if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true

@tdas tdas Oct 31, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we are going to manually add labels. so its not fine if we choose backport a backport PR. for example

  • main PR --> apply label: "backport branch-0.3" --> merge
  • 0.3 PR from merged changes in main PR --> conflict --> resolved conflict --> apply label: "backport branch-0.2" --> merge
    • This is useful because now we know that after conflict resolution this diff may work for 0.2 as well, so backport this to 0.2
  • 0.2 PR from merged changes in 0.3 PR
    wdyt?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me, thanks @tdas for the work !

Signed-off-by: Tathagata Das <[email protected]>
@tdas
tdas enabled auto-merge (squash) October 31, 2025 20:28
@tdas
tdas disabled auto-merge November 1, 2025 00:19
@tdas
tdas merged commit 8c8f324 into unitycatalog:main Nov 1, 2025
@tdas tdas mentioned this pull request Nov 4, 2025
1 of 4 tasks
tdas added a commit that referenced this pull request Nov 5, 2025
**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
  - [ ] If there is a related issue, make sure it is linked to this PR.
- [ ] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

  **Description of changes**
Follow up of - #1148
It created this backport PR -
#1150
But the problem is that the commit in the backported PR dont have the
signoff. So even if there are no conflicts, the PR cannot be readily
merged.
So I modified the backport GitHub action to automatically amend backport
commits with sign-off. The workflow now:
- Extracts the original commit author's name and email from each
backport branch
- Amends the commit with `--signoff` flag using the original author's
credentials
  - Force pushes the updated branch

This ensures all backported commits include proper sign-off from the
original author.

Signed-off-by: Tathagata Das <[email protected]>
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