Skip to content

Commit 64ef874

Browse files
Add cherry-pick action-workflow (#15226)
1 parent 2b24344 commit 64ef874

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

.github/workflows/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for the React Native Windows repository.
4+
5+
## Available Workflows
6+
7+
### Cherry-pick Commit to Branch
8+
9+
**File:** `cherry-pick-commit.yml`
10+
11+
Cherry-picks a specific commit into a target branch.
12+
13+
**Usage:**
14+
15+
1. Go to the Actions tab in the GitHub repository
16+
2. Select "Cherry-pick Commit to Branch" workflow
17+
3. Click "Run workflow"
18+
4. Enter the required inputs:
19+
- **Commit SHA or ID**: The full commit hash or short SHA of the commit to cherry-pick
20+
- **Target branch name**: The branch where you want to cherry-pick the commit
21+
22+
**Example:**
23+
24+
- Commit ID: `d1a95351e5203a6c0651cf73885cd7ea99e7d2b9`
25+
- Target branch: `0.79-stable`
26+
27+
**Notes:**
28+
29+
- The workflow will fail if there are merge conflicts during cherry-pick
30+
- If conflicts occur, you'll need to resolve them manually
31+
- The commit will be pushed directly to the target branch after successful cherry-pick
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
name: Cherry-pick Commit to Branch
3+
4+
'on':
5+
workflow_dispatch:
6+
inputs:
7+
commit_id:
8+
description: 'Commit SHA or ID to cherry-pick'
9+
required: true
10+
type: string
11+
target_branch:
12+
description: 'Target branch name to cherry-pick into'
13+
required: true
14+
type: string
15+
16+
jobs:
17+
cherry-pick:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Install GitHub CLI
22+
run: |
23+
sudo apt update
24+
sudo apt install -y gh
25+
26+
- name: Authenticate GitHub CLI
27+
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
28+
29+
- name: Clone repository
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
gh auth setup-git
34+
gh repo clone "${{ github.repository }}" repo
35+
cd repo
36+
git fetch origin
37+
38+
- name: Configure Git
39+
working-directory: ./repo
40+
run: |
41+
git config user.name "React-Native-Windows Bot"
42+
git config user.email "53619745+rnbot@users.noreply.github.com"
43+
44+
- name: Checkout target branch
45+
working-directory: ./repo
46+
run: |
47+
git checkout "${{ github.event.inputs.target_branch }}"
48+
git pull origin "${{ github.event.inputs.target_branch }}"
49+
50+
- name: Cherry-pick commit
51+
working-directory: ./repo
52+
run: |
53+
COMMIT_ID="${{ github.event.inputs.commit_id }}"
54+
TARGET_BRANCH="${{ github.event.inputs.target_branch }}"
55+
56+
echo "🍒 Cherry-picking commit $COMMIT_ID into branch $TARGET_BRANCH"
57+
58+
if git cherry-pick "$COMMIT_ID"; then
59+
echo "✅ Cherry-pick successful"
60+
else
61+
echo "❌ Cherry-pick failed with conflicts"
62+
echo "Conflict details:"
63+
git status
64+
exit 1
65+
fi
66+
67+
- name: Push changes
68+
working-directory: ./repo
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
COMMIT_ID="${{ github.event.inputs.commit_id }}"
73+
TARGET_BRANCH="${{ github.event.inputs.target_branch }}"
74+
75+
echo "📤 Pushing cherry-picked commit to $TARGET_BRANCH"
76+
REPO_URL="https://x-access-token:${GH_TOKEN}@github.com"
77+
REPO_URL="${REPO_URL}/${{ github.repository }}.git"
78+
git push "$REPO_URL" "$TARGET_BRANCH"
79+
echo "✅ Successfully cherry-picked $COMMIT_ID to $TARGET_BRANCH"

0 commit comments

Comments
 (0)