Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a backport GitHub Actions workflow #3519

Closed

Conversation

dunxen
Copy link
Contributor

@dunxen dunxen commented Jan 10, 2025

Now that we have release branches such as 0.1, we would like some convenient way to backport certain PRs that target main.

This workflow was adapted from the one in the NixOS/nixpkgs repo and works as follows:

To attempt to automatically create a PR that backports a PR merged to main, add the backport X.Y label to the merged PR where X.Y is an existing release branch (e.g backport 0.1). If the action is able to cherry-pick all the commits of the merged PR into a new PR targeting the X.Y branch, then the backport PR will be created. Otherwise, the GitHub Actions bot will reply to the merged PR indicating that there were merge conflicts and that you will manually need to backport by cherry-picking and resolving those conflicts.

NOTE: For this action to work we must allow GitHub Actions to create pull requests. This checkbox can be found in settings at Actions > General > Workflow permissions.

Now that we have release branches such as 0.1, we would like some convenient
way to backport certain PRs that target `main`.

This workflow was adapted from the one in the NixOS/nixpkgs repo and works
as follows:

To attempt to automatically create a PR that backports a PR merged to main,
add the `backport X.Y` label to the merged PR where `X.Y` is an existing release
branch (e.g `backport 0.1`). If the action is able to cherry-pick all the
commits of the merged PR into a new PR targeting the `X.Y` branch, then
the backport PR will be created. Otherwise, the GitHub Actions bot will
reply to the merged PR indicating that there were merge conflicts and
that you will manually need to backport by cherry-picking and resolving those
conflicts.
@dunxen dunxen force-pushed the 2025-01-backportingworkflow branch from 7765a94 to 1bcfca4 Compare January 10, 2025 08:38
@TheBlueMatt
Copy link
Collaborator

NOTE: For this action to work we must allow GitHub Actions to create pull requests. This checkbox can be found in settings at Actions > General > Workflow permissions.

Okay, should be good to go.

jobs:
backport:
name: Backport Pull Request
if: github.repository_owner == 'lightningdevkit' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait when exactly will this run? It looks like it requires github.event.pull_request.merged which implies it'll only actually run on merges?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested that it runs once labelling a merged pull request.


permissions:
pull-requests: write
contents: write
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ugh, why do people have to build things based on actions and not based on bots...I wonder if this isn't easier to do by just having a bot with its own github user run in python and hit the github API...

with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Create backport PRs
uses: korthout/backport-action@be567af183754f6a5d831ae90f648954763f17f5 # v3.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Grrr, this is a pile of typescript...I find typescript fairly hard to review, let alone typescript garbage that has dependencies on basic shit like "build a string".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think we could find something or put something together based on a bot that hits the GH API. Manually cherry picking for now should be not too terrible.

@dunxen
Copy link
Contributor Author

dunxen commented Jan 13, 2025

Working on a simple bot with a GitHub user account. Then you'd just need to set up one webhook in the repo settings for trigger on label with a secret (to avoid spam) to hit an endpoint of the bot. That should be much better than this.

@dunxen dunxen closed this Jan 13, 2025
@dunxen dunxen deleted the 2025-01-backportingworkflow branch January 13, 2025 10:38
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