`prep.rake`と`staging.rake`の作成

This commit is contained in:
Kazuhiro MUSASHI 2023-01-01 18:45:23 +09:00
parent e49e7b2ce5
commit e2c08640d1
2 changed files with 51 additions and 0 deletions

36
tasks/prep.rake Executable file
View File

@ -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

15
tasks/staging.rake Executable file
View File

@ -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