From 2c3ac1feaa6153bbe23b4182aef8a82d60ca71d5 Mon Sep 17 00:00:00 2001 From: Michal Miszczyszyn Date: Wed, 3 Oct 2018 21:16:06 +0200 Subject: [PATCH] Update build scripts --- .gitignore | 1 + .version | 1 + components/layout/Layout.tsx | 4 +-- deploy-production.sh | 15 ---------- deploy-staging.sh | 15 ---------- deploy.sh | 29 +++++++++++++++++++ ssh-script-clean-staging.sh | 7 ----- ...clean-production.sh => ssh-script-clean.sh | 2 +- ssh-script-deploy-production.sh | 9 ------ ssh-script-deploy-staging.sh | 9 ------ ssh-script-deploy.sh | 9 ++++++ 11 files changed, 43 insertions(+), 58 deletions(-) delete mode 100755 deploy-production.sh delete mode 100755 deploy-staging.sh create mode 100755 deploy.sh delete mode 100644 ssh-script-clean-staging.sh rename ssh-script-clean-production.sh => ssh-script-clean.sh (53%) delete mode 100644 ssh-script-deploy-production.sh delete mode 100644 ssh-script-deploy-staging.sh create mode 100644 ssh-script-deploy.sh diff --git a/.gitignore b/.gitignore index f3615a3f..258dc949 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ npm-debug.log /public/ /server/*.js /server/*.map +.version diff --git a/.version b/.version index e69de29b..aa72a3d8 100644 --- a/.version +++ b/.version @@ -0,0 +1 @@ +staging:master:f5a8bcaf0216d79d171229c1295bdb77025cfe10 diff --git a/components/layout/Layout.tsx b/components/layout/Layout.tsx index 094b6a6c..5669295a 100644 --- a/components/layout/Layout.tsx +++ b/components/layout/Layout.tsx @@ -23,9 +23,9 @@ export default class Layout extends React.Component { return ( - Fefaq.pl • {title} + Fefaq.pl • {title} - +
diff --git a/deploy-production.sh b/deploy-production.sh deleted file mode 100755 index 49fd1415..00000000 --- a/deploy-production.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -DIR=`dirname $0` - - -echo "👉 Building…" -NODE_ENV=production npm run build -echo "👉 Cleaning" -ssh sinpai@s18.mydevil.net 'bash -s' < $DIR/ssh-script-clean-production.sh -echo "👉 Uploading…" -rsync -avP -e ssh --exclude=node_modules --exclude=".git" --include="**/.*" ./ sinpai@s18.mydevil.net:/home/sinpai/domains/app.fefaq.pl/public_nodejs/ -echo "👉 Installing…" -ssh sinpai@s18.mydevil.net 'bash -s' < $DIR/ssh-script-deploy-production.sh -echo "👉 Done! 😎" diff --git a/deploy-staging.sh b/deploy-staging.sh deleted file mode 100755 index e2598dd7..00000000 --- a/deploy-staging.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -DIR=`dirname $0` - - -echo "👉 Building…" -NODE_ENV=staging npm run build -echo "👉 Cleaning" -ssh sinpai@s18.mydevil.net 'bash -s' < $DIR/ssh-script-clean-staging.sh -echo "👉 Uploading…" -rsync -avP -e ssh --exclude=node_modules --exclude=".git" --include="**/.*" ./ sinpai@s18.mydevil.net:/home/sinpai/domains/staging.fefaq.pl/public_nodejs/ -echo "👉 Installing…" -ssh sinpai@s18.mydevil.net 'bash -s' < $DIR/ssh-script-deploy-staging.sh -echo "👉 Done! 😎" diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 00000000..a6191ca2 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +DIR=`dirname $0` + + +if [[ "$1" == "production" ]]; then + SUBDOMAIN="app" +elif [[ "$1" == "staging" ]]; then + SUBDOMAIN="staging" +else + echo 'Incorrect environment. "production" or "staging" allowed.' + exit 1 +fi + +ENVIRONMENT=$1 + +echo $ENVIRONMENT:`git rev-parse --abbrev-ref HEAD`:`git rev-parse HEAD` > .version +echo "🥁 VERSION: " `cat .version` + +echo "👉 Building…" +NODE_ENV=$ENVIRONMENT npm run build +echo "👉 Cleaning" +ssh sinpai@s18.mydevil.net SUBDOMAIN=$SUBDOMAIN 'bash -s' < $DIR/ssh-script-clean.sh +echo "👉 Uploading…" +rsync -avP -e ssh --exclude=node_modules --exclude=".git" --include="**/.*" ./ sinpai@s18.mydevil.net:/home/sinpai/domains/$SUBDOMAIN.fefaq.pl/public_nodejs/ +echo "👉 Installing…" +ssh sinpai@s18.mydevil.net SUBDOMAIN=$SUBDOMAIN 'bash -s' < $DIR/ssh-script-deploy.sh +echo "👉 Done! 😎" diff --git a/ssh-script-clean-staging.sh b/ssh-script-clean-staging.sh deleted file mode 100644 index 702dc19f..00000000 --- a/ssh-script-clean-staging.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -e - -cd /home/sinpai/domains/staging.fefaq.pl/public_nodejs -echo "👉 Cleaning" -rm -rf .next -rm -rf public diff --git a/ssh-script-clean-production.sh b/ssh-script-clean.sh similarity index 53% rename from ssh-script-clean-production.sh rename to ssh-script-clean.sh index 702dc19f..4d5795bd 100644 --- a/ssh-script-clean-production.sh +++ b/ssh-script-clean.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -cd /home/sinpai/domains/staging.fefaq.pl/public_nodejs +cd /home/sinpai/domains/$SUBDOMAIN.fefaq.pl/public_nodejs echo "👉 Cleaning" rm -rf .next rm -rf public diff --git a/ssh-script-deploy-production.sh b/ssh-script-deploy-production.sh deleted file mode 100644 index 73959e83..00000000 --- a/ssh-script-deploy-production.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -cd /home/sinpai/domains/app.fefaq.pl/public_nodejs -npm i -f -echo "👉 Restarting…" -devil www restart app.fefaq.pl -echo "👉 Fetching…" -curl -I app.fefaq.pl diff --git a/ssh-script-deploy-staging.sh b/ssh-script-deploy-staging.sh deleted file mode 100644 index 82ad7134..00000000 --- a/ssh-script-deploy-staging.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -cd /home/sinpai/domains/staging.fefaq.pl/public_nodejs -npm i -f -echo "👉 Restarting…" -devil www restart staging.fefaq.pl -echo "👉 Fetching…" -curl -I staging.fefaq.pl diff --git a/ssh-script-deploy.sh b/ssh-script-deploy.sh new file mode 100644 index 00000000..cf75a909 --- /dev/null +++ b/ssh-script-deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +cd /home/sinpai/domains/$SUBDOMAIN.fefaq.pl/public_nodejs +npm i -f +echo "👉 Restarting…" +devil www restart $SUBDOMAIN.fefaq.pl +echo "👉 Fetching…" +curl -I https://$SUBDOMAIN.fefaq.pl/