-
Notifications
You must be signed in to change notification settings - Fork 817
Add backport GitHub Action #4228
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "targetBranchChoices": ["branch_10x", "branch_9x"], | ||
| "branchLabelMapping": { | ||
| "^backport-to-(.+)$": "$1" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||||||||||||||||
| # This workflow automatically backports merged PRs to maintenance branches when | ||||||||||||||||||||||||||||||||||||||||||
| # a backport label is applied (e.g. "backport-to-branch_10x" or "backport-to-branch_9x"). | ||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||
| # For more information, see https://github.com/marketplace/actions/backport-action | ||||||||||||||||||||||||||||||||||||||||||
| name: Backport PR | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||
| pull_request_target: | ||||||||||||||||||||||||||||||||||||||||||
| types: ["labeled", "closed"] | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||
| backport: | ||||||||||||||||||||||||||||||||||||||||||
| name: Backport PR | ||||||||||||||||||||||||||||||||||||||||||
| if: github.repository == 'apache/solr' && github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) | ||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||
| - name: Backport Action | ||||||||||||||||||||||||||||||||||||||||||
| uses: sorenlouv/backport-github-action@v11 | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| uses: sorenlouv/backport-github-action@v11 | |
| uses: sorenlouv/backport-github-action@9d9e4d81a4c3f0a2d2c6b8a9e7f3c2b1d4f5a6b7 # v11 |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These log-printing steps will fail the job if the log files are not present (e.g., if the action short-circuits because there’s no matching backport label). Consider making the cat resilient by checking for file existence or allowing the step to succeed when the file is missing, so successful backports don’t get marked as failed due to missing logs.
| run: cat ~/.backport/backport.info.log | |
| - name: Debug log | |
| if: ${{ failure() }} | |
| run: cat ~/.backport/backport.debug.log | |
| run: | | |
| if [ -f "$HOME/.backport/backport.info.log" ]; then | |
| cat "$HOME/.backport/backport.info.log" | |
| else | |
| echo "Info log not found at $HOME/.backport/backport.info.log" | |
| fi | |
| - name: Debug log | |
| if: ${{ failure() }} | |
| run: | | |
| if [ -f "$HOME/.backport/backport.debug.log" ]; then | |
| cat "$HOME/.backport/backport.debug.log" | |
| else | |
| echo "Debug log not found at $HOME/.backport/backport.debug.log" | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The job-level
if:only checksmergedand the absence of a literalbackportlabel, so this workflow will run on any merged PR close/label event (including PRs merged into maintenance branches) even when nobackport-to-*label is present. Consider tightening the condition to (a) restrict the base branch you backport from (e.g.,github.event.pull_request.base.ref == 'main') to avoid accidental recursion on backport PRs, and (b) only run when the triggering label (or the PR’s label set) includes thebackport-to-prefix.