Skip to content

Commit da45d49

Browse files
committed
sync dev with main via sync branch
1 parent 5f46ea3 commit da45d49

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/sync-main-to-dev.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
push:
1212
branches:
1313
- main
14+
workflow_dispatch: {}
1415

1516
jobs:
1617
sync-branch:
@@ -30,17 +31,25 @@ jobs:
3031
id: pull_request
3132
shell: bash
3233
run: |
33-
EXISTS=$(gh pr list --base $BASE --head $HEAD \
34+
SYNC="$BASE-sync-with-$HEAD"
35+
git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE
36+
git merge origin/$HEAD
37+
git checkout origin/dev src/*
38+
git checkout origin/dev tests/*
39+
git commit -m "Restored src/* and tests/*"
40+
git push -u origin $SYNC
41+
42+
EXISTS=$(gh pr list --base $BASE --head $SYNC \
3443
--json number --jq '.[] | .number')
3544
if [ ! -z "$EXISTS" ]; then
36-
echo "PR #$EXISTS already wants to merge $HEAD into $BASE"
45+
echo "PR #$EXISTS already wants to merge $SYNC into $BASE"
3746
exit 0
3847
fi
3948
40-
gh pr create --base $BASE --head $HEAD \
49+
gh pr create --base $BASE --head $SYNC \
4150
--label "Housekeeping" \
42-
--title "$BASE: update from $HEAD" \
43-
--body "Merge \`$HEAD\` into \`$BASE\`."
51+
--title "$BASE: sync with $HEAD" \
52+
--body "Merge relevant changes from \`$HEAD\` into \`$BASE\`."
4453
env:
4554
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
4655
HEAD: main

0 commit comments

Comments
 (0)