From e2c08640d12fb2234ee64e672978c7ea076c8697 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 1 Jan 2023 18:45:23 +0900 Subject: [PATCH] =?UTF-8?q?`prep.rake`=E3=81=A8`staging.rake`=E3=81=AE?= =?UTF-8?q?=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/prep.rake | 36 ++++++++++++++++++++++++++++++++++++ tasks/staging.rake | 15 +++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 tasks/prep.rake create mode 100755 tasks/staging.rake diff --git a/tasks/prep.rake b/tasks/prep.rake new file mode 100755 index 0000000..b575571 --- /dev/null +++ b/tasks/prep.rake @@ -0,0 +1,36 @@ +#!/usr/bin/env rake + +def os + @os ||= ( + host_os = RbConfig::CONFIG['host_os'] + case host_os + when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ + :windows + when /darwin|mac os/ + :macosx + when /linux/ + :linux + when /solaris|bsd/ + :unix + else + :unknown + end + ) +end + +desc 'Preparation for Generating the HTML Pages' +task :prep do + cd 'content/' do + if os == :linux + sh 'find . -type f -name "*.mde" | xargs --no-run-if-empty rm || true' + sh 'find . -type f -name "*.md-e" | xargs --no-run-if-empty rm || true' + else + sh 'find . -type f -name "*.mde" | xargs rm || true' + sh 'find . -type f -name "*.md-e" | xargs rm || true' + end + end + + cd 'public' do + sh 'rm -rf *' + end +end diff --git a/tasks/staging.rake b/tasks/staging.rake new file mode 100755 index 0000000..47d719d --- /dev/null +++ b/tasks/staging.rake @@ -0,0 +1,15 @@ +#!/usr/bin/env rake + +require 'find' + +desc 'Deploy the hugo contents to the server' +task :stag => [ :prep ] do + sh 'hugo -e staging -v --minify' + + sh 'find public -type f -name "*.gz" -delete' + + sh 'find public/ -type f | egrep "\.(css|js|png|jpg|html|JPG|PNG|CSS|JS|HTML)$" | xargs -n 1 -i% -P 0 sh -c "cp % %.bk && gzip % && mv %.bk %"' + + sh 'ssh -p 10022 webadm@10.0.1.166 "rm -rf /var/www/test-everun/*"' + sh 'rsync -e "ssh -p 10022" -rltvz --omit-dir-times --delete public/ webadm@10.0.1.166:/var/www/test-everun' +end