rsync/rsync-docker.sh
L3D c7bfb1a69a
Some checks failed
shellchecking ansible-docker.sh / build (push) Successful in 14s
Yamllint GitHub Actions / Yamllint (push) Successful in 6s
hadolint Dockerfile / build (push) Failing after 7s
vars
2023-05-12 00:26:36 +02:00

39 lines
1.1 KiB
Bash
Executable file

#! /usr/bin/env bash
set -Eeuo pipefail
set -x
# Generates client.
# env:
# SOURCE: ${{ inputs.source }}
# DESTINATION: ${{ inputs.destionation }}
# HOST: ${{ inputs.host }}
# USER: ${{ inputs.user }}
# SSHKEY: ${{ inputs.sshkey }}
echo "${SOURCE} or $SOURCE or ..."
rsync::ssh() {
: "${GITHUB_WORKSPACE?GITHUB_WORKSPACE has to be set. Did you use the actions/checkout action?}"
: "${SSHKEY?Please provide a SSH Private Key (ED25519).}"
: "${HOST?Destination Server}"
pushd "${GITHUB_WORKSPACE}"
printf "Add SSH Private Key"
mkdir ~/.ssh
chmod 700 ~/.ssh
echo "${SSHKEY}" | tee ~/.ssh/id_ed25519 > /dev/null
chmod 400 ~/.ssh/id_ed25519
ssh-keyscan -t ed25519 "${HOST}" | tee -a ~/.ssh/known_hosts
}
rsync::transfer() {
: "${GITHUB_WORKSPACE?GITHUB_WORKSPACE has to be set. Did you use the actions/checkout action?}"
: "${SOURCE?Define File to copy.}"
: "${DESTINATION?Define File destination.}"
: "${HOST?Destination Server}"
: "${USER?Destination User}"
pushd "${GITHUB_WORKSPACE}"
rsync --progress "${SOURCE}" "${USER}@${HOST}:${DESTINATION}"
}
rsync::ssh
rsync::transfer