Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
git-mirror:
runs-on: ubuntu-latest
steps:
- uses: zent-contrib/git-branch-sync-action@v1
- uses: zent-contrib/sync-git-branch@v1
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
with:
source-branch: main
destination-repo: "git@bitbucket.org:<org>/<repo>.git"
```
```
10 changes: 6 additions & 4 deletions sync-git-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ REPO_DIR="repo"
echo "SOURCE=$SOURCE_REPO:$SOURCE_BRANCH"
echo "DESTINATION=$DESTINATION_REPO:$DESTINATION_BRANCH"

# Only clone the branch we want to sync
git clone --single-branch --branch "$SOURCE_BRANCH" "$SOURCE_REPO" "$REPO_DIR"
cd "$REPO_DIR"
rm -fr "$REPO_DIR"
git clone "$SOURCE_REPO" "$REPO_DIR" --origin source && cd "$REPO_DIR"

git remote add mirror "$DESTINATION_REPO"
git push mirror "$SOURCE_BRANCH:$DESTINATION_BRANCH"
git fetch source '+refs/heads/*:refs/heads/*' --update-head-ok

git push -f mirror "$SOURCE_BRANCH:$DESTINATION_BRANCH"