GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Backport 4.1: Automatic backporting workflow from 4.1 to 4.2 (#16274) · netty/netty@a80f333

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • backport-41.yml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/backport-41.yml‎

Copy file name to clipboard
+105Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Auto Backport to 4.1
2+
on:
3+
pull_request_target:
4+
types:
5+
- closed
6+
- labeled
7+
branches:
8+
- '4.2'
9+
10+
jobs:
11+
backport:
12+
name: "Backporting to 4.1"
13+
concurrency:
14+
group: backporting-${{ github.event.pull_request.number }}
15+
cancel-in-progress: true
16+
if: github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'needs-cherry-pick-4.1')
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v6
21+
with:
22+
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_PEM }}
23+
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
24+
fetch-depth: '0' # Cherry-pick needs full history
25+
26+
- name: Setup git configuration
27+
run: |
28+
git config --global user.email "[email protected]"
29+
git config --global user.name "Netty Project Bot"
30+
31+
- name: Create backport PR branch and cherry-pick
32+
id: cherry-pick
33+
run: |
34+
MERGE_COMMIT="${{ github.event.pull_request.merge_commit_sha }}"
35+
echo "Backporting commit: $MERGE_COMMIT"
36+
37+
BACKPORT_BRANCH="backport-pr-${{ github.event.pull_request.number }}-to-4.1"
38+
git fetch origin 4.1:4.1
39+
git checkout -b "$BACKPORT_BRANCH" 4.1
40+
41+
if git cherry-pick -x "$MERGE_COMMIT"; then
42+
echo "Cherry-pick successful"
43+
else
44+
echo "Cherry-pick failed - conflicts detected"
45+
git cherry-pick --abort
46+
exit 1
47+
fi
48+
echo "branch=$BACKPORT_BRANCH" >> "$GITHUB_OUTPUT"
49+
50+
- name: Push backport branch
51+
id: push
52+
if: steps.cherry-pick.outcome == 'success'
53+
run: |
54+
if ! git push origin "${{ steps.cherry-pick.outputs.branch }}"; then
55+
echo "Backport branch push failed"
56+
exit 1
57+
fi
58+
59+
- name: Create pull request
60+
if: steps.cherry-pick.outcome == 'success'
61+
uses: actions/github-script@v8
62+
with:
63+
script: |
64+
const { data: pr } = await github.rest.pulls.create({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
title: `Backport 4.1: ${context.payload.pull_request.title}`,
68+
head: '${{ steps.cherry-pick.outputs.branch }}',
69+
base: '4.1',
70+
body: `Backport of #${context.payload.pull_request.number} to 4.1\n` +
71+
`Cherry-picked commit: ${context.payload.pull_request.merge_commit_sha}\n\n---\n` +
72+
`${context.payload.pull_request.body || ''}`
73+
});
74+
console.log(`Created backport PR: ${pr.html_url}`);
75+
await github.rest.issues.createComment({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
issue_number: context.payload.pull_request.number,
79+
body: `Backport PR for 4.1: #${pr.number}`
80+
});
81+
82+
- name: Report cherry-pick conflicts
83+
if: failure() && steps.cherry-pick.outcome != 'success'
84+
uses: actions/github-script@v8
85+
with:
86+
script: |
87+
await github.rest.issues.createComment({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
issue_number: context.payload.pull_request.number,
91+
body: `Could not create automatic backport PR.\nGot conflicts when cherry-picking onto 4.1.`
92+
});
93+
94+
- name: Report backport branch push failure
95+
if: failure() && steps.push.outcome != 'success'
96+
uses: actions/github-script@v8
97+
with:
98+
script: |
99+
await github.rest.issues.createComment({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
issue_number: context.payload.pull_request.number,
103+
body: `Could not create automatic backport PR.\n`+
104+
`I could cherry-pick onto 4.1 just fine, but pushing the new branch failed.`
105+
});

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.