Skip to content

Update auto-merge.yml ready to deploy #18

Update auto-merge.yml ready to deploy

Update auto-merge.yml ready to deploy #18

Workflow file for this run

name: Auto Merge Develop to Main
on:
push:
branches:
- Develop # Trigger action on push to Develop
jobs:
merge:
runs-on: ubuntu-latest
permissions:
contents: write # ✅ Grant write access for pushing changes
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensure full history for merge
- 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: 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 }} # ✅ Authenticate using GitHub token