# Set up private key in a five SSH_KEY_FILE=/tmp/gitea-pages-ssh-key-$(date +%s) # set up ssh private key echo "${INPUT_SSH_KEY}" >> "${SSH_KEY_FILE}" chmod 600 "${SSH_KEY_FILE}" if [ ! -s "${SSH_KEY_FILE}" ]; then echo "Missing ssh key, aborting deploy." exit 1 fi # set up ssh remote key echo "${INPUT_HOST} ${INPUT_HOST_KEY}" >> ~/.ssh/known_hosts # check if directory present if [ ! -d "${INPUT_DIRECTORY}" ]; then echo "Directory ${INPUT_DIRECTORY} does not exist, aborting deploy." exit 1 fi # optionally: create index if "${INPUT_INDEX}"; then if [ ! -e "${INPUT_DIRECTORY}/index.html" ]; then tree "${INPUT_DIRECTORY}" -a -H "." \ -D \ --charset utf-8 \ -T "${INPUT_INDEX_TITLE}" \ > "${INPUT_DIRECTORY}/index.html" echo "Added index" else echo "File index.html exists, not overriding." fi fi # deploy via ssh tar -C "${INPUT_DIRECTORY}" -czf - . \ | ssh -o "IdentitiesOnly=yes" -i "${SSH_KEY_FILE}" \ "${INPUT_HOST_USER}@${INPUT_HOST}" # remove ssh key rm "${SSH_KEY_FILE}"