-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Backport workflow #10435
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
Merged
ziggie1984
merged 2 commits into
lightningnetwork:master
from
ziggie1984:test-backport-workflow
Dec 12, 2025
+665
−0
Merged
Backport workflow #10435
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| name: Backport | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [closed, labeled] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: read | ||
|
|
||
| jobs: | ||
| backport: | ||
| name: Backport PR | ||
| runs-on: ubuntu-latest | ||
| # Only run on merged PRs with backport labels. | ||
| # Labels must match pattern: backport-v* (e.g., backport-v0.20.x-branch). | ||
| # This excludes labels like "backport candidate" or "backport-candidate". | ||
| if: | | ||
| github.event.pull_request.merged == true && | ||
| contains(join(github.event.pull_request.labels.*.name, ','), 'backport-v') | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.event.pull_request.base.ref }} | ||
|
|
||
| - name: Validate target branches exist | ||
| id: validate | ||
| shell: bash | ||
| run: | | ||
| # Extract all backport labels | ||
| labels='${{ toJSON(github.event.pull_request.labels.*.name) }}' | ||
| echo "All labels: $labels" | ||
|
|
||
| # Parse labels and extract branch names | ||
| # Only match labels starting with "backport-v" to exclude labels like | ||
| # "backport candidate" or "backport-candidate" | ||
| backport_labels=$(echo "$labels" | jq -r '.[] | select(startswith("backport-v"))') | ||
|
|
||
| if [ -z "$backport_labels" ]; then | ||
| echo "::error::No valid backport labels found (must start with 'backport-v')" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Found backport labels:" | ||
| echo "$backport_labels" | ||
|
|
||
| # Check each target branch exists | ||
| missing_branches=() | ||
| valid_branches=() | ||
| while IFS= read -r label; do | ||
| # Extract branch name (everything after "backport-") | ||
| branch_name="${label#backport-}" | ||
| echo "Checking if branch exists: $branch_name" | ||
|
|
||
| # Check if branch exists in remote | ||
| if ! git ls-remote --heads origin "$branch_name" | grep -q "$branch_name"; then | ||
| echo "::warning::Target branch '$branch_name' does not exist (from label '$label')" | ||
| missing_branches+=("$branch_name") | ||
| else | ||
| echo "✓ Branch '$branch_name' exists" | ||
| valid_branches+=("$branch_name") | ||
| fi | ||
| done <<< "$backport_labels" | ||
|
|
||
| # Report validation results | ||
| if [ ${#missing_branches[@]} -gt 0 ]; then | ||
| echo "::warning::The following target branches do not exist and will be skipped: ${missing_branches[*]}" | ||
| echo "::warning::Please check the branch names or create the branches before retrying" | ||
| fi | ||
|
|
||
| # Only fail if ALL branches are invalid | ||
| if [ ${#valid_branches[@]} -eq 0 ]; then | ||
| echo "::error::No valid target branches found. All backport labels reference non-existent branches." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✓ Found ${#valid_branches[@]} valid target branch(es): ${valid_branches[*]}" | ||
| if [ ${#missing_branches[@]} -gt 0 ]; then | ||
| echo "⚠ Skipping ${#missing_branches[@]} invalid branch(es): ${missing_branches[*]}" | ||
| fi | ||
|
|
||
| - name: Create backport PRs | ||
| # Uses version v3.4, we pin to a hash here. For more details to | ||
| # available versions, see: | ||
| # https://github.com/korthout/backport-action/releases. | ||
| uses: korthout/backport-action@d07416681cab29bf2661702f925f020aaa962997 | ||
| with: | ||
| # Automatically detect target branches from labels. | ||
| # Labels must be in format: backport-v0.20.x-branch (must start | ||
| # with "backport-v"). This excludes labels like "backport candidate" | ||
| # or "backport-candidate". The pattern extracts everything after | ||
| # "backport-" as the branch name. | ||
| label_pattern: '^backport-(v.+)$' | ||
|
|
||
| # GitHub token for creating PRs. | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # PR title format - shows it's a backport with original PR number. | ||
| pull_title: '[${target_branch}] Backport #${pull_number}: ${pull_title}' | ||
|
|
||
| # PR description template - links back to original PR. | ||
| pull_description: |- | ||
| Backport of #${pull_number} | ||
|
|
||
| --- | ||
|
|
||
| ${pull_description} | ||
|
|
||
| # Automatically add labels to backport PRs. | ||
| # The 'no-changelog' label skips the release notes check in CI. | ||
| labels: no-changelog | ||
|
|
||
| # Merge strategy - skip merge commits, use cherry-pick only. | ||
| merge_commits: skip | ||
|
|
||
| # If conflicts occur, create a draft PR with conflict markers. | ||
| experimental: '{"conflict_resolution": "draft_commit_conflicts"}' | ||
Roasbeef marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.