File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 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+ env :
34+ SOURCE_BRANCH : ${{ inputs.source_branch }}
35+ TARGET_BRANCH : ${{ inputs.target_branch }}
36+ run : |
37+ echo "Source: $SOURCE_BRANCH"
38+ echo "Target: $TARGET_BRANCH"
39+
40+ if [ -z "$SOURCE_BRANCH" ] || [ -z "$TARGET_BRANCH" ]; then
41+ echo "Error: Source and target branches must be provided."
42+ exit 1
43+ fi
44+
45+ SOURCE_COMMIT_SHA=$(git rev-parse "origin/$SOURCE_BRANCH")
46+ git checkout "$TARGET_BRANCH"
47+ git pull origin "$TARGET_BRANCH" --ff-only
48+
49+ COMMIT_MESSAGE="Merge commit '$SOURCE_COMMIT_SHA' into $TARGET_BRANCH"
50+ echo "Using commit message: $COMMIT_MESSAGE"
51+
52+ git merge --no-ff "origin/$SOURCE_BRANCH" -m "$COMMIT_MESSAGE"
53+
54+ echo "Pushing changes to $TARGET_BRANCH..."
55+ git push origin "$TARGET_BRANCH"
You can’t perform that action at this time.
0 commit comments