File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Sync Branches
2+ on :
3+ workflow_run :
4+ workflows : [Release]
5+ types : [completed]
6+ branches : [main]
7+ workflow_dispatch :
8+ branches : [main]
9+ permissions :
10+ contents : read
11+ jobs :
12+ sync-branches :
13+ name : sync dev branch with main
14+ runs-on : ubuntu-latest
15+ if : ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
16+ steps :
17+ - name : generate token
18+ id : generate_token
19+ uses : tibdex/github-app-token@v1
20+ with :
21+ app_id : ${{ secrets.RELEASE_BOT_APP_ID }}
22+ private_key : ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
23+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
24+ with :
25+ fetch-depth : 0 # Need full history for branch operations
26+ token : ${{ steps.generate_token.outputs.token }}
27+ - name : sync dev with main
28+ run : |
29+ git config --global user.name '${{ vars.RELEASE_BOT_GIT_AUTHOR_NAME }}'
30+ git config --global user.email '${{ vars.RELEASE_BOT_GIT_AUTHOR_EMAIL }}'
31+
32+ # Fetch all branches
33+ git fetch origin
34+
35+ # Get the latest release tag
36+ LATEST_TAG=$(git describe --tags --abbrev=0 origin/main)
37+
38+ # Check if dev branch exists
39+ if git ls-remote --heads origin dev | grep -q 'dev'; then
40+ # Checkout dev branch
41+ git checkout dev
42+
43+ # Merge main into dev with release version in commit message
44+ # Add --strategy-option=theirs to automatically resolve conflicts in favor of main
45+ git merge --no-edit main -m "Merge 'main' into 'dev' after release $LATEST_TAG"
46+
47+ # Push the merged changes
48+ git push origin dev
49+ else
50+ # If dev doesn't exist, create it from main
51+ git checkout -b dev
52+ git push origin dev
53+ fi
You can’t perform that action at this time.
0 commit comments