From e49e7b2ce5b987ede602b2662f30a2df0d045ca7 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 1 Jan 2023 18:45:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?`public`=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=82=92=E7=AE=A1=E7=90=86=E5=AF=BE=E8=B1=A1=E5=A4=96?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1c84042..67dcaeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .hugo_build.lock assets resources +public From e2c08640d12fb2234ee64e672978c7ea076c8697 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 1 Jan 2023 18:45:23 +0900 Subject: [PATCH 2/2] =?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