-
Notifications
You must be signed in to change notification settings - Fork 23
39 lines (35 loc) · 1.26 KB
/
merge-main-to-branches.yml
File metadata and controls
39 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This workflow automatically merges the 'main' branch into 'dev' and 'release' branches
# whenever changes are pushed to 'main', without requiring manual confirmation.
name: Merge Main to branches
on:
push:
branches:
- main
jobs:
merge-to-branch:
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ 'dev', 'release' ]
name: main -> ${{ matrix.branch }}
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge main into ${{ matrix.branch }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git checkout ${{ matrix.branch }}; then
echo "[INFO] Branch '${{ matrix.branch }}' does not exist. Skipping merge."
exit 0
fi
if ! git merge --no-ff origin/main -m "chore: merge main into ${{ matrix.branch }} [skip ci]"; then
echo "[ERROR] Merge conflict detected when merging main into ${{ matrix.branch }}. Manual intervention required."
exit 1
fi
git push origin ${{ matrix.branch }}