Conversation
Co-authored-by: dsmiley <377295+dsmiley@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds automated backporting support to streamline cherry-picking merged PRs from main onto Solr maintenance branches via a GitHub Actions workflow plus repository backport configuration.
Changes:
- Introduces a
pull_request_targetworkflow to run the backport action on merged PRs when backport labels are present. - Adds
.backportrc.jsonto define target branches and mapbackport-to-*labels to branch names.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| .github/workflows/backport.yml | New workflow that triggers the backport action on merged PR events and prints action logs. |
| .backportrc.json | New backport configuration defining eligible branches and label→branch mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pull-requests: write | ||
| steps: | ||
| - name: Backport Action | ||
| uses: sorenlouv/backport-github-action@v11 |
There was a problem hiding this comment.
This workflow runs with contents: write / pull-requests: write on pull_request_target and invokes a third-party action by tag (sorenlouv/backport-github-action@v11). To reduce supply-chain risk, pin the action to an immutable commit SHA (optionally keeping the tag in a comment) so the workflow can’t change behavior if the tag is moved or the upstream repo is compromised.
| uses: sorenlouv/backport-github-action@v11 | |
| uses: sorenlouv/backport-github-action@9d9e4d81a4c3f0a2d2c6b8a9e7f3c2b1d4f5a6b7 # v11 |
| run: cat ~/.backport/backport.info.log | ||
|
|
||
| - name: Debug log | ||
| if: ${{ failure() }} | ||
| run: cat ~/.backport/backport.debug.log |
There was a problem hiding this comment.
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 |
| jobs: | ||
| backport: | ||
| name: Backport PR | ||
| if: github.repository == 'apache/solr' && github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) |
There was a problem hiding this comment.
The job-level if: only checks merged and the absence of a literal backport label, so this workflow will run on any merged PR close/label event (including PRs merged into maintenance branches) even when no backport-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 the backport-to- prefix.
| if: github.repository == 'apache/solr' && github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) | |
| if: github.repository == 'apache/solr' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(join(github.event.pull_request.labels.*.name, ' '), 'backport-to-') |
Adds automated PR backporting via sorenlouv/backport-github-action to streamline cherry-picking merged PRs onto maintenance branches.
Changes
.github/workflows/backport.yml— Workflow triggered onpull_request_target(labeled/closed). Runs only on merged PRs that don't carry thebackportlabel (prevents re-backporting auto-created backport PRs). Requirescontents: writeandpull-requests: writepermissions..backportrc.json— Configures available target branches and the label-to-branch mapping:{ "targetBranchChoices": ["branch_10x", "branch_9x"], "branchLabelMapping": { "^backport-to-(.+)$": "$1" } }Usage
Apply a label to a PR before or after merging:
backport-to-branch_10xbranch_10xbackport-to-branch_9xbranch_9xOn merge, the action opens a new PR with the cherry-picked commit(s) against the target branch.