-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (37 loc) · 1.1 KB
/
branch-syncer.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
name: BranchSyncer
on:
workflow_run:
workflows:
- Releaser
types:
- completed
branches:
- main
permissions:
contents: write
env:
SOURCE_BRANCH: main
TARGET_BRANCH: dev
jobs:
sync-branch:
name: Sync branch source into target
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SRGH_TOKEN }}
- name: Configure git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Sync branch source into target
run: |
set -e
git fetch origin ${{ env.SOURCE_BRANCH }} ${{ env.TARGET_BRANCH }}
git checkout ${{ env.TARGET_BRANCH }}
git fetch origin ${{ env.TARGET_BRANCH }}
git merge origin/${{ env.SOURCE_BRANCH }} || (echo "Merge conflict detected" && exit 1)
git push origin ${{ env.TARGET_BRANCH }}