88jobs :
99 merge :
1010 runs-on : ubuntu-latest
11+ permissions :
12+ contents : write # ✅ Grant write access for pushing changes
13+
1114 steps :
1215 - name : Checkout code
1316 uses : actions/checkout@v2
1417 with :
15- fetch-depth : 0 # Ensure full history for merge operations
18+ fetch-depth : 0 # Ensure full history for merge
1619
1720 - name : Get last commit message on Develop
1821 id : last_commit
1922 run : |
2023 LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
21- echo "Last commit message: $LAST_COMMIT_MSG"
2224 echo "commit_message=$LAST_COMMIT_MSG" >> $GITHUB_ENV
2325
2426 - name : Set up Git
2527 run : |
26- git config user.name "github-actions"
27- git config user.email "github-actions@ github.com"
28+ git config user.name "github-actions[bot] "
29+ git config user.email "github-actions[bot]@users.noreply. github.com"
2830
2931 - name : Checkout main branch
3032 run : |
@@ -37,16 +39,19 @@ jobs:
3739
3840 if [[ "$COMMIT_MSG_LOWER" == *"ready to deploy"* ]]; then
3941 echo "Commit message matches, attempting merge."
40-
41- # Merge and detect conflicts
4242 if git merge origin/Develop --no-ff -m "Merge Develop into main"; then
43- git push origin main
44- echo "Merge successful, pushed to main."
43+ echo "Merge successful."
4544 else
46- echo "Merge conflicts detected. Stopping merge ."
45+ echo "Merge conflicts detected. Aborting ."
4746 git merge --abort
4847 exit 1
4948 fi
5049 else
5150 echo "Commit message does not match, skipping merge."
5251 fi
52+
53+ - name : Push changes to main
54+ run : |
55+ git push origin main
56+ env :
57+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # ✅ Authenticate using GitHub token
0 commit comments