Skip to content

Commit e29ab27

Browse files
committed
update backport actions
1 parent 461510a commit e29ab27

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

.github/actions/backport/action.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ inputs:
88
base_branch:
99
description: The base branch to backport to (i.e., solana-v2.0, solana-v1.18)
1010
required: true
11+
github_token:
12+
description: GitHub token for authentication
13+
required: true
1114

1215
runs:
1316
using: "composite"
1417
steps:
1518
- name: Fetch pull request data
1619
env:
17-
GH_TOKEN: ${{ github.token }}
20+
GITHUB_TOKEN: ${{ inputs.github_token }}
1821
shell: bash
1922
run: |
2023
MERGE_COMMIT=${{ github.sha }}
@@ -36,30 +39,28 @@ runs:
3639
else
3740
echo "No backport detected."
3841
fi
39-
40-
- name: Checkout base branch
41-
if : ${{ env.BACKPORT == 'true' }}
42-
uses: actions/checkout@v4
43-
with:
44-
ref: ${{ inputs.base_branch }}
4542
4643
- name: Backport changes
4744
if: ${{ env.BACKPORT == 'true' }}
4845
env:
49-
GITHUB_TOKEN: ${{ github.token }}
46+
GITHUB_TOKEN: ${{ inputs.github_token }}
5047
shell: bash
5148
run: |
5249
git config user.name "github-actions[bot]"
5350
git config user.email "github-actions[bot]@users.noreply.github.com"
5451
55-
BACKPORT_BRANCH="backport-${{ env.PR_NUMBER }}-to-${{ inputs.base_branch }}"
52+
git fetch --all
53+
54+
BASE_BRANCH="${{ inputs.base_branch }}"
55+
BACKPORT_BRANCH="backport-${{ github.sha }}-to-${{ inputs.base_branch }}"
56+
git checkout $BASE_BRANCH
5657
git checkout -b $BACKPORT_BRANCH
5758
58-
git cherry-pick $MERGE_COMMIT || (git cherry-pick --abort && exit 1)
59+
git cherry-pick -X theirs --allow-empty $MERGE_COMMIT
5960
6061
git push origin $BACKPORT_BRANCH
6162
62-
gh pr create \
63+
gh pr create -v \
6364
--base $BASE_BRANCH \
6465
--head $BACKPORT_BRANCH \
6566
--title "Backport PR #${{ env.PR_NUMBER }} to $BASE_BRANCH" \
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Backport to solana-v1.18
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
backport:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
pull-requests: write
13+
contents: write
14+
15+
steps:
16+
- name: Git Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Debug Permissions
20+
run: gh auth status
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Backport to v1.18
25+
uses: ./.github/actions/backport
26+
with:
27+
label: v1.18
28+
base_branch: solana-v1.18
29+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/backport-2.0.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ jobs:
88
backport:
99
runs-on: ubuntu-latest
1010

11+
permissions:
12+
pull-requests: write
13+
contents: write
14+
1115
steps:
1216
- name: Git Checkout
1317
uses: actions/checkout@v4
18+
19+
- name: Debug Permissions
20+
run: gh auth status
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1423

1524
- name: Backport to v2.0
1625
uses: ./.github/actions/backport
1726
with:
1827
label: v2.0
1928
base_branch: solana-v2.0
29+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)