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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Adapted from https://github.com/NixOS/nixpkgs/blob/24a8c64/.github/workflows/backport.yml
# Under the MIT license with original copyright:
# Copyright (c) 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors

name: Backport
on:
pull_request_target:
types: [closed, labeled]

# WARNING:
# When extending this action, be aware that $GITHUB_TOKEN allows write access to
# the GitHub repository. This means that it should not evaluate user input in a
# way that allows code injection.

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...


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.

runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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.

with:
# If you want any labels copied over from the original PR, use copy_labels_pattern.
# See: https://github.com/korthout/backport-action#backport-action
# copy_labels_pattern: 'severity:\ssecurity'
pull_description: |-
Bot-based backport to `${target_branch}`, triggered by a label in #${pull_number}.
* [ ] Please ensure that this backport is acceptable for release.
Loading