Merge pull request #36 from kazu634/task-modify

Create the deploy tasks for production and staging
This commit is contained in:
Kazuhiro MUSASHI 2019-06-29 18:35:07 +07:00 committed by GitHub
commit 9d6d065efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 5 deletions

6
tasks/build.rake → tasks/prep.rake Executable file → Normal file
View File

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

20
tasks/production.rake Normal file
View File

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

View File

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