mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
Tasks are now namespaced by concern: build:*, draft:*, publish:*, quality:*. bake.rb is reduced to load path setup and the default task.
34 lines
1 KiB
Ruby
34 lines
1 KiB
Ruby
PUBLISH_HOST = "mudge".freeze
|
|
PRODUCTION_PUBLISH_DIR = "/var/www/samhuri.net/public".freeze
|
|
BETA_PUBLISH_DIR = "/var/www/beta.samhuri.net/public".freeze
|
|
GEMINI_PUBLISH_DIR = "/var/gemini/samhuri.net".freeze
|
|
|
|
# Publish to beta/staging server
|
|
def beta
|
|
call("build:beta")
|
|
run_rsync(local_paths: ["www/"], publish_dir: BETA_PUBLISH_DIR, dry_run: false, delete: true)
|
|
end
|
|
|
|
# Publish Gemini capsule to production
|
|
def gemini
|
|
call("build:gemini")
|
|
run_rsync(local_paths: ["gemini/"], publish_dir: GEMINI_PUBLISH_DIR, dry_run: false, delete: true)
|
|
end
|
|
|
|
# Publish to production server
|
|
def production
|
|
call("build:release")
|
|
run_rsync(local_paths: ["www/"], publish_dir: PRODUCTION_PUBLISH_DIR, dry_run: false, delete: true)
|
|
call("publish:gemini")
|
|
end
|
|
|
|
private
|
|
|
|
def run_rsync(local_paths:, publish_dir:, dry_run:, delete:)
|
|
command = ["rsync", "-aKv", "-e", "ssh -4"]
|
|
command << "--dry-run" if dry_run
|
|
command << "--delete" if delete
|
|
command.concat(local_paths)
|
|
command << "#{PUBLISH_HOST}:#{publish_dir}"
|
|
abort "Error: rsync failed." unless system(*command)
|
|
end
|