1
0
mirror of https://github.com/kolaente/Simple-Git-Deploy.git synced 2023-09-04 21:52:08 +00:00
Simple-Git-Deploy/src/Simple-Git-Deploy/deploy.sh

26 lines
702 B
Bash
Raw Normal View History

2017-04-26 18:58:42 +00:00
#!/bin/bash
2017-04-27 18:46:47 +00:00
while getopts ':k:g:d:' OPTION ; do
case "$OPTION" in
k) KEY=$OPTARG;;
g) GIT_URL=$OPTARG;;
d) DEPLOY_DIR=$OPTARG;;
*) echo "Unknown parameter"
esac
done
echo "-----------------------------"
echo "Key: ${KEY}"
echo "Git-Url: ${GIT_URL}"
echo "Deploy-Dir: ${DEPLOY_DIR}"
echo "----------------------------"
rm -Rf /tmp/git-deploy
ssh-agent bash -c "ssh-add ${KEY}; git clone ${GIT_URL} /tmp/git-deploy"
rm -Rf /tmp/git-deploy/.git # Remove the Git Folder
# Empty the deploy-directory without deleting itself
rm -Rf ${DEPLOY_DIR}/.* 2> /dev/null
rm -Rf ${DEPLOY_DIR}/*
# Move the newly downloaded files to the deploy-folder
mv -fT /tmp/git-deploy ${DEPLOY_DIR}