-
Notifications
You must be signed in to change notification settings - Fork 1
35 lines (30 loc) · 993 Bytes
/
sync-branches.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
name: Sync main to feature branches
on:
push:
branches:
- main
jobs:
branch-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up git
run: |
git config --global user.name 'myeolinmalchi'
git config --global user.email '[email protected]'
- name: Get all feature branches
id: get-branches
run: |
git fetch --all
git branch -r | grep 'origin/feature/' | sed 's/origin\///' > feature_branches.txt
echo "::set-output name=branches::$(cat feature_branches.txt | tr '\n' ' ')"
- name: Push changes to all feature branches
run: |
for branch in ${{ steps.get-branches.outputs.branches }}; do
git checkout $branch
git merge main -X theirs || git merge --abort
git push origin $branch
done