1111 push :
1212 branches :
1313 - main
14+ workflow_dispatch : {}
1415
1516jobs :
1617 sync-branch :
@@ -25,22 +26,36 @@ jobs:
2526
2627 - name : Checkout repository
2728 uses : actions/checkout@v5
29+ with :
30+ fetch-depth : 0
31+ token : ${{ steps.generate-token.outputs.token }}
2832
2933 - name : Create pull request
3034 id : pull_request
3135 shell : bash
3236 run : |
33- EXISTS=$(gh pr list --base $BASE --head $HEAD \
37+ git config user.name ${GITHUB_ACTOR}
38+ git config user.email "[email protected] " 39+ SYNC="$BASE-sync-with-$HEAD"
40+
41+ git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE
42+ git merge origin/$HEAD -m "Merge $HEAD into $SYNC"
43+ git checkout origin/$BASE src/*
44+ git checkout origin/$BASE tests/*
45+ git commit -m "Restored src/* and tests/*" || echo ""
46+ git push -u origin $SYNC
47+
48+ EXISTS=$(gh pr list --base $BASE --head $SYNC \
3449 --json number --jq '.[] | .number')
3550 if [ ! -z "$EXISTS" ]; then
36- echo "PR #$EXISTS already wants to merge $HEAD into $BASE"
51+ echo "PR #$EXISTS already wants to merge $SYNC into $BASE"
3752 exit 0
3853 fi
3954
40- gh pr create --base $BASE --head $HEAD \
55+ gh pr create --base $BASE --head $SYNC \
4156 --label "Housekeeping" \
42- --title "$BASE: update from $HEAD" \
43- --body "Merge \`$HEAD\` into \`$BASE\`."
57+ --title "$BASE: sync with $HEAD" \
58+ --body "Merge relevant changes from \`$HEAD\` into \`$BASE\`."
4459 env :
4560 GH_TOKEN : ${{ steps.generate-token.outputs.token }}
4661 HEAD : main
0 commit comments