From a21dafc30b7a68845efbc64660892272eb5506e6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 5 Jan 2016 08:53:49 +0000 Subject: [PATCH] Added basics for CI deployment script --- scripts/ci-deploy.sh | 16 ++++++++++++++++ scripts/deploy.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 scripts/ci-deploy.sh create mode 100755 scripts/deploy.sh diff --git a/scripts/ci-deploy.sh b/scripts/ci-deploy.sh new file mode 100755 index 0000000..eed3570 --- /dev/null +++ b/scripts/ci-deploy.sh @@ -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)" diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..2acb898 --- /dev/null +++ b/scripts/deploy.sh @@ -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