pages/action.sh

32 lines
749 B
Bash
Executable File

# 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}"
# set up ssh remote key
echo "${INPUT_HOST} ${INPUT_HOST_KEY}" >> ~/.ssh/known_hosts
# optionally: create index
if [ "${INPUT_INDEX}" ]; then
if [ ! -e "${INPUT_DIRECTORY}/index.html" ]; then
tree -H "${INPUT_DIRECTORY}" \
-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}"