Skip to content

Commit d5c085f

Browse files
committed
feat(github): Add reusable merge workflow
1 parent 65172bd commit d5c085f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Merge Branch
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
source_branch:
7+
description: 'The source branch to merge from (e.g., main, testnet)'
8+
required: true
9+
type: string
10+
target_branch:
11+
description: 'The target branch to merge into (e.g., testnet, mainnet)'
12+
required: true
13+
type: string
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
merge:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Git user
28+
run: |
29+
git config user.name "github-actions[bot]"
30+
git config user.email "github-actions[bot]@users.noreply.github.com"
31+
32+
- name: Merge and Push
33+
run: |
34+
echo "Source: ${{ inputs.source_branch }}"
35+
echo "Target: ${{ inputs.target_branch }}"
36+
37+
SOURCE_COMMIT_SHA=$(git rev-parse origin/${{ inputs.source_branch }})
38+
39+
git checkout ${{ inputs.target_branch }}
40+
git pull origin ${{ inputs.target_branch }} --ff-only
41+
42+
COMMIT_MESSAGE="Merge commit '$SOURCE_COMMIT_SHA' into ${{ inputs.target_branch }}"
43+
echo "Using commit message: $COMMIT_MESSAGE"
44+
45+
git merge --no-ff origin/${{ inputs.source_branch }} -m "$COMMIT_MESSAGE"
46+
47+
echo "Pushing changes to ${{ inputs.target_branch }}..."
48+
git push origin ${{ inputs.target_branch }}

0 commit comments

Comments
 (0)