You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
codefirst-docdeployer/entrypoint.sh

48 lines
1.2 KiB

#!/usr/bin/env bash
echo "Repository name : $DRONE_REPO_NAME"
echo "Repository owner: $DRONE_REPO_OWNER"
echo "Generating and deploying documentation for user $DRONE_REPO_OWNER and repository $DRONE_REPO_NAME"
while [ "$1" ]; do
case "$1" in
"-d" | "--dir")
DOC_DIR="$2"
shift 1
;;
"-t" | "--type")
GENERATOR_NAME="$2"
GENERATOR_SCRIPT="/generators/$GENERATOR_NAME.sh"
if [ ! -f "$GENERATOR_SCRIPT" ]; then
echo "unknown generator type, please enter a valid generator ($(ls /generators | cut -d "." -f1 | tr "\n" " "))" >&2
exit 1
fi
shift 1
;;
*)
echo "unknown option $1" >&2
exit 1
;;
esac
shift
done
if [ ! "$GENERATOR_SCRIPT" ] || [ ! "$DOC_DIR" ]; then
echo "option -t <type> obligatoire" >&2
fi
. "$GENERATOR_SCRIPT"
generate "$DOC_DIR" # generates doc using the wanted generator
SERVER_TARGET="/usr/share/nginx/html/$DRONE_REPO_OWNER/$DRONE_REPO_NAME/"
# launches rsync in archive, verbose and compression mode
# creates target directory ($SERVER_TARGET) on server
# then sends generated files int the server directory
rsync -avz \
--rsync-path="mkdir -p \"$SERVER_TARGET\" && rsync" \
-e "ssh -o StrictHostKeyChecking=no" \
--delete "$GEN_PATH"/* root@nginx:"$SERVER_TARGET"