From fc5d0a22c60c1bfa0c351a1e6c171d75a340a7e4 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 29 Jun 2019 19:30:52 +0800 Subject: [PATCH 2/4] Separate the preparation part from the `build.rake`. --- tasks/{build.rake => prep.rake} | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename tasks/{build.rake => prep.rake} (94%) mode change 100755 => 100644 diff --git a/tasks/build.rake b/tasks/prep.rake old mode 100755 new mode 100644 similarity index 94% rename from tasks/build.rake rename to tasks/prep.rake index 864b1f9..8199497 --- a/tasks/build.rake +++ b/tasks/prep.rake @@ -18,8 +18,8 @@ def os ) end -desc 'Generate the HTML pages' -task :build do +desc 'Preparation for Generating the HTML Pages' +task :prep do cd 'content/' do if os == :linux sh 'grep -l -r ecx.images-amazon.com | sort | uniq | xargs --no-run-if-empty sed -ie "s/http:\/\/ecx.images-amazon.com/https:\/\/images-na.ssl-images-amazon.com/g"' @@ -37,6 +37,4 @@ task :build do cd 'public' do sh 'rm -rf *' end - - sh 'hugo -e staging -v' end From a93b333da98b882c807afed1ae66723507416892 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 29 Jun 2019 16:25:33 +0800 Subject: [PATCH 3/4] Create staging deploy task. --- tasks/{deploy.rake => staging.rake} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename tasks/{deploy.rake => staging.rake} (86%) diff --git a/tasks/deploy.rake b/tasks/staging.rake similarity index 86% rename from tasks/deploy.rake rename to tasks/staging.rake index 12fc496..1dc18b5 100644 --- a/tasks/deploy.rake +++ b/tasks/staging.rake @@ -3,12 +3,15 @@ require 'find' desc 'Deploy the hugo contents to the server' -task :deploy => [:build] do +task :stag => [:prep] do + sh 'hugo -e staging -v' + sh 'find public -type f -name "*.gz" -delete' Find.find("#{Dir::pwd}/public") do |f| if f =~ /\.(css|js|png|jpg|JPG|PNG|CSS|JS)$/ && FileTest.file?(f) sh "gzip -c #{f} > #{f}.gz" + sh "rm #{f}" end end From a892daa154e0a6d4849d8d76e0f965906f11e073 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 29 Jun 2019 19:31:00 +0800 Subject: [PATCH 4/4] Create the production deploy task. --- tasks/production.rake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tasks/production.rake diff --git a/tasks/production.rake b/tasks/production.rake new file mode 100644 index 0000000..b38e6ed --- /dev/null +++ b/tasks/production.rake @@ -0,0 +1,20 @@ +#!/usr/bin/env rake + +require 'find' + +desc 'Deploy the hugo contents to the server' +task :prod => [:prep] do + sh 'hugo -v' + + sh 'find public -type f -name "*.gz" -delete' + + Find.find("#{Dir::pwd}/public") do |f| + if f =~ /\.(css|js|png|jpg|JPG|PNG|CSS|JS)$/ && FileTest.file?(f) + sh "gzip -c #{f} > #{f}.gz" + sh "rm #{f}" + end + end + + sh 'ssh -p 10022 webadm@10.0.1.234 "rm -rf /var/www/blog/*"' + sh 'rsync -e "ssh -p 10022" -rltvz --omit-dir-times --delete public/ webadm@10.0.1.234:/var/www/blog' +end