forked from basho/basho_docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-service.rb
More file actions
executable file
·32 lines (31 loc) · 873 Bytes
/
deploy-service.rb
File metadata and controls
executable file
·32 lines (31 loc) · 873 Bytes
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
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'json'
$running = false
post '/deploy' do
if ENV['AWS_CLOUDFRONT_DIST_ID'] == '' || ENV['AWS_S3_BUCKET'] == ''
puts "AWS_CLOUDFRONT_DIST_ID and AWS_S3_BUCKET env vars are required"
return "AWS_CLOUDFRONT_DIST_ID and AWS_S3_BUCKET env vars are required"
end
ENV['RIAK_DOCS_LANG'] = 'en'
ENV['DEPLOY'] = 'true'
return "no data" unless params[:payload]
push = JSON.parse(params[:payload])
return "in use" if $running
if push["ref"] == "refs/heads/publish"
Thread.new do
$running = true
puts "running background deploy"
# pull from private
puts `git pull origin publish`
`rm -rf build`
puts `bundle exec middleman build`
puts "completed background deploy"
$running = false
end
"deploying"
end
""
end