Merge remote-tracking branch 'origin/Develop' into Develop #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Merge Develop to Main | |
| on: | |
| push: | |
| branches: | |
| - Develop | |
| jobs: | |
| merge: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get last commit message on Develop | |
| id: last_commit | |
| run: | | |
| LAST_COMMIT_MSG=$(git log -1 --pretty=%B) | |
| echo "commit_message=$LAST_COMMIT_MSG" >> $GITHUB_ENV | |
| - name: Set up Git with Your Credentials | |
| run: | | |
| git config user.name "RNViththagan" | |
| git config user.email "[email protected]" | |
| - name: Checkout main branch | |
| run: | | |
| git fetch origin main | |
| git checkout main | |
| - name: Merge Develop into main (if commit message matches) | |
| run: | | |
| COMMIT_MSG_LOWER=$(echo "$commit_message" | tr '[:upper:]' '[:lower:]') | |
| if [[ "$COMMIT_MSG_LOWER" == *"ready to deploy"* ]]; then | |
| echo "Commit message matches, attempting merge." | |
| if git merge origin/Develop --no-ff -m "Merge Develop into main"; then | |
| echo "Merge successful." | |
| else | |
| echo "Merge conflicts detected. Aborting." | |
| git merge --abort | |
| exit 1 | |
| fi | |
| else | |
| echo "Commit message does not match, skipping merge." | |
| fi | |
| - name: Push changes to main | |
| run: | | |
| git push origin main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |