-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
61 lines (50 loc) · 1.49 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
desc "Remove output folder"
task :clean do
sh 'rm -rf ./output'
end
desc "Package for deployment"
task :package => :clean do
sh './scripts/create-package.sh'
end
namespace :deploy do
def validate_package_is_available
unless File.exist?("./output/deploy.sh") && File.exist?("./output/fuseki-package.tar.gz")
fail "Please make sure the deploy package exist. To create the package run 'rake package'"
end
end
def deploy(server)
validate_package_is_available
configure_deploy_ssh_key(server)
sh "./output/deploy.sh #{server}"
end
def configure_deploy_ssh_key(server)
command = <<-eos
echo "$DEPLOY_SSH_KEY" > ~/.ssh/deploy-key
chmod 0600 ~/.ssh/deploy-key
printf "\nHost #{server}\nUserKnownHostsFile /dev/null\nIdentityFile ~/.ssh/deploy-key\n" >> $HOME/.ssh/config
eos
sh command if ENV['CI']
end
def get_server_from_env_variable(name)
fail "Please set the server address using the environment variable #{name}" if ENV[name].to_s.empty?
ENV[name]
end
desc "Deploy to localhost"
task :local => :package do
deploy('localhost')
end
desc "Deploy to test environment"
task :test do
deploy("app-server.dev")
end
desc "Deploy to staging environment"
task :staging do
server = get_server_from_env_variable('OD4D_STAGING_SERVER')
deploy(server)
end
desc "Deploy to production environment"
task :production do
server = get_server_from_env_variable('OD4D_PROD_SERVER')
deploy(server)
end
end