Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/autodeploy config #132

Merged
merged 10 commits into from
Apr 2, 2019
Merged
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ jobs:
docker pull talentmap/$DOCKER_HUB_REPO:$TAG
docker tag talentmap/$DOCKER_HUB_REPO:$TAG talentmap/$DOCKER_HUB_REPO:$BRANCH
docker push talentmap/$DOCKER_HUB_REPO:$BRANCH
deploy:
<<: *default-docker-node
steps:
- add_ssh_keys
- run:
command: ssh -o StrictHostKeyChecking=no ec2-user@ec2-52-204-49-159.compute-1.amazonaws.com ./deploy.sh
workflows:
version: 2
build_and_test:
Expand All @@ -167,6 +173,12 @@ workflows:
# Disabled see 1368 - pa11y:
# requires:
# - docker-build
- deploy:
requires:
- yarn
filters:
branches:
only: dev
- zap:
requires:
- docker-build
Expand Down
12 changes: 5 additions & 7 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#! /bin/bash

# "Automation" of the front end app deployment.
# * Gets code from the `dev` branch
# * generates certs
Expand All @@ -9,10 +7,10 @@
# * copies static build dir to apache dir
# * restarts apache and pm2

curr_date=`date "+%Y-%m-%d_%H-%M-%S"`

# delete backup if exists
[ -d State-TalentMAP-dev-BACKUP ] && rm -rf State-TalentMAP-dev-BACKUP
# backup current version if it exists
[ -d State-TalentMAP-dev ] && mv State-TalentMAP-dev State-TalentMAP-dev-$curr_date
[ -d State-TalentMAP-dev ] && cp -r State-TalentMAP-dev State-TalentMAP-dev-BACKUP

# get code
wget -O dev.zip https://github.com/MetaPhase-Consulting/State-TalentMAP/archive/dev.zip
Expand Down Expand Up @@ -58,11 +56,11 @@ export NODE_ENV=production
yarn build

# backup the html dir if present
[ -d /var/www/html ] && sudo mv /var/www/html /var/www/html-$curr_date
[ -d /var/www/html ] && sudo mv /var/www/html /var/www/html-BACKUP
# move build to html
sudo cp -R build /var/www/html
# restart apache
sudo apachectl restart

# restart the pm2 process
pm2 restart all
pm2 restart all --update-env