Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
source_branch: "main"
destination_repo: "destination_org/repository"
destination_branch: "main"
destination_force_push: "1" # optional, whether to force push to destination
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} # optional
source_ssh_private_key: ${{ secrets.SOURCE_SSH_PRIVATE_KEY }} # optional, will override `SSH_PRIVATE_KEY`
destination_ssh_private_key: ${{ secrets.DESTINATION_SSH_PRIVATE_KEY }} # optional, will override `SSH_PRIVATE_KEY`
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
destination_branch:
description: Branch name to sync to
required: true
destination_force_push:
description: Whether to force push to destination
required: false
ssh_private_key:
description: SSH key used to authenticate with source and destination ssh urls provided (optional if public or https url with authentication)
required: false
Expand All @@ -37,4 +40,5 @@ runs:
- ${{ inputs.source_repo }}
- ${{ inputs.source_branch }}
- ${{ inputs.destination_repo }}
- ${{ inputs.destination_branch }}
- ${{ inputs.destination_branch }}
- ${{ inputs.destination_force_push }}
7 changes: 6 additions & 1 deletion git-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SOURCE_REPO=$1
SOURCE_BRANCH=$2
DESTINATION_REPO=$3
DESTINATION_BRANCH=$4
DESTINATION_FORCE_PUSH=$5
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is unused.


if ! echo $SOURCE_REPO | grep -Eq ':|@|\.git\/?$'; then
if [[ -n "$SSH_PRIVATE_KEY" || -n "$SOURCE_SSH_PRIVATE_KEY" ]]; then
Expand Down Expand Up @@ -48,4 +49,8 @@ if [[ -n "$DESTINATION_SSH_PRIVATE_KEY" ]]; then
git config --local core.sshCommand "/usr/bin/ssh -i ~/.ssh/dst_rsa"
fi

git push destination "${SOURCE_BRANCH}:${DESTINATION_BRANCH}" -f
if [[ -n "$SOURCE_SSH_PRIVATE_KEY" ]]; then
git push destination "${SOURCE_BRANCH}:${DESTINATION_BRANCH}" -f
else
git push destination "${SOURCE_BRANCH}:${DESTINATION_BRANCH}"
fi