From 1f412e21e5bfd09ac9717a1fb09b329ba54c2fc2 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 18 Sep 2018 20:46:42 +0200 Subject: Fix deploy scripts. + Ask for branch to deploy for staging (default is current branch) + Fix shared path in deploy script + Fix uploading of config and env files if they don't exist --- config/deploy.rb | 7 ++++--- config/deploy/staging.rb | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/deploy.rb b/config/deploy.rb index bd5965c..8240df3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -4,6 +4,7 @@ lock '3.11.0' set :application, 'registration' set :repo_url, 'https://code.volse.no/norsk-urskog-registrations.git' set :deploy_to, '/usr/home/norskurskog/www/registration' +set :shared_directory, File.join(fetch(:deploy_to), 'shared') append :linked_files, 'config.yml', '.env' append :linked_dirs, 'public/uploads', 'bin', 'log', 'tmp' @@ -25,11 +26,11 @@ namespace :deploy do + "accept_registrations:\n" + " start: YYYY.MM.DD\n" + " stop: YYYY.MM.DD\n" - IO.write(t.name, template) + IO.write(f.name, template) end file '.env' do |f| - IO.write(t.name, "NUREG_BASE=/\n") + IO.write(f.name, "export NUREG_BASE=/\n") end before 'check:linked_files', :upload_config => ['config.yml', '.env'] do |t| @@ -37,7 +38,7 @@ namespace :deploy do t.prerequisites.each do |r| target_file = File.join(fetch(:shared_directory), r) unless test("[ -f #{target_file} ]") - upload!(t.prerequisites.first, target_file) + upload!(r, target_file) end end end diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb index 469e3e0..20732be 100644 --- a/config/deploy/staging.rb +++ b/config/deploy/staging.rb @@ -1,2 +1,4 @@ server 'volse.local', user: 'norskurskog', roles: %w{app db web} -set :branch, 'staging' + +# Ask for which branch to deploy, default is current branch. +ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call -- cgit v1.2.3