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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Rsync files from a GitHub repo to a destination server over SSH
| `SSH_PRIVATE_KEY` | The private key part of an SSH key pair. The public key part should be added to the `authorized_keys` on the destination server. |
| `SSH_USERNAME` | The username to use when connecting to the destination server |
| `SSH_HOSTNAME` | The hostname of the destination server |
| `SSH_PORT` | The port number of the destination server (default: 22) |

## Required arguments

Expand Down
11 changes: 10 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ mkdir -p "$SSH_PATH"
echo "$SSH_PRIVATE_KEY" > "$SSH_PATH/deploy_key"
chmod 600 "$SSH_PATH/deploy_key"

# Create SSH config file
touch "$SSH_PATH/config"
echo "Host rsync_target" >> "$SSH_PATH/config"
echo " HostName $SSH_HOSTNAME" >> "$SSH_PATH/config"
echo " User $SSH_USERNAME" >> "$SSH_PATH/config"
echo " IdentityFile $SSH_PATH/deploy_key" >> "$SSH_PATH/config"
echo " Port ${SSH_PORT:-22}" >> "$SSH_PATH/config"
echo " StrictHostKeyChecking no" >> "$SSH_PATH/config"

# Do deployment
sh -c "rsync ${INPUT_RSYNC_OPTIONS} -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' ${GITHUB_WORKSPACE}${INPUT_RSYNC_SOURCE} ${SSH_USERNAME}@${SSH_HOSTNAME}:${INPUT_RSYNC_TARGET}"
sh -c "rsync -e 'ssh -F \"$SSH_PATH/config\"' ${INPUT_RSYNC_OPTIONS} ${GITHUB_WORKSPACE}${INPUT_RSYNC_SOURCE} rsync_target:${INPUT_RSYNC_TARGET}"