1
Fork 0

Added basics for CI deployment script

This commit is contained in:
Jake Howard 2016-01-05 08:53:49 +00:00
parent 2c08618d03
commit a21dafc30b
2 changed files with 45 additions and 0 deletions

16
scripts/ci-deploy.sh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
RED='tput setaf 1'
NC='tput sgr 0'
YELLOW='tput setaf 3'
GREEN='tput setaf 2'
if [ -z "$CIRCLE_PROJECT_USERNAME"]; then
echo "$($RED)You need to be running on CircleCI to deploy!$($NC)"
exit 1
fi
ssh web@theorangeone.net 'bash -s' < ./scripts/deploy.sh
echo "$($GREEN)Deployment complete!$($NC)"

29
scripts/deploy.sh Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
RED='tput setaf 1'
NC='tput sgr 0'
YELLOW='tput setaf 3'
GREEN='tput setaf 2'
cd
echo "$($YELLOW)>> Fetching Repository...$($NC)"
ctf fetch RealOrangeOne/theorangeone.net master deployment
sleep 15
echo "$($YELLOW)>> Entering Project...$($NC)"
project_dir="$(\ls -1dt ./*/ | head -n 1)"
previous_dir = "$(\ls -1dt ./*/ | head -n 2)"
cd project_dira
echo "$($YELLOW)>> Building Project...$($NC)"
ctf project run build
ctf project run manage.py migrate
echo "$($YELLOW)>> Routing Project...$($NC)"
ident=$project_dir + ":development:web"
ctf router theorangeone.net --ident %ident
echo "$($YELLOW)>> Destroying Previous Project...$($NC)"
cd -
cd previous_dir
ctf project stop
cd -
rm -rf previous_dir