From a892daa154e0a6d4849d8d76e0f965906f11e073 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 29 Jun 2019 19:31:00 +0800 Subject: [PATCH] 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