pages/action.sh

37 lines
892 B
Bash
Raw Normal View History

2023-10-17 15:49:51 +02:00
# 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
2023-10-17 15:58:57 +02:00
# check if directory present
if [ ! -d "${INPUT_DIRECTORY}" ]; then
echo "Directory ${INPUT_DIRECTORY} does not exist, aborting deploy."
fi
2023-10-17 15:49:51 +02:00
# 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}"