-
Notifications
You must be signed in to change notification settings - Fork 11
49 lines (41 loc) · 1.33 KB
/
sync-dev-main.yml
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
40
41
42
43
44
45
46
47
48
49
name: Sync Development to Main
on:
push:
branches:
- development
workflow_dispatch:
jobs:
sync-branches:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
- name: Setup SSH Keys and known_hosts
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh
echo "$DEPLOY_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Fetch all branches
run: |
git fetch --all
git fetch --tags
- name: Sync development to main
run: |
git checkout main
git merge origin/development --ff-only -m "Fast-forward main to latest development"
git push [email protected]:${GITHUB_REPOSITORY}.git main
- name: Handle merge conflicts or non-fast-forward situations
if: failure()
run: |
echo "⚠️ Unable to fast-forward. There might be commits on main that are not in development."
echo "Please review the branches and merge manually if necessary."
exit 1