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
|
# File 'lib/scms/s3deploy.rb', line 5
def S3Deploy.sync(pub, config, mimetypefile)
ENV["S3CONF"] = config
ENV["AWS_CALLING_FORMAT"] = "SUBDOMAIN"
ENV["S3SYNC_MIME_TYPES_FILE"] = mimetypefile
s3yamlpath=File.join(config, "_s3config.yml")
settings = YAML.load_file(s3yamlpath)
throw "No bucket defined in _s3config.yml settings file" if settings['bucket'] == nil
ScmsUtils.boldlog( "Syncing with Amazon S3: #{settings['bucket']}" )
exclude = "(\\.svn$)|(\\.git$)|(^_)"
if settings['ignore'] != nil
exclude = "#{exclude}|(#{settings["ignore"]})"
end
cmd = "s3sync"
params = "--exclude=\"#{exclude}\" --progress --make-dirs --recursive"
Dir.glob("#{pub}/_*/").each do |f|
privatedir = File.basename(f)
ScmsUtils.log( "Backing up: #{privatedir} (private)" )
privateparams = "#{params} \"#{pub}/#{privatedir}/\" #{settings['bucket']}:#{privatedir}/"
ScmsUtils.run(cmd, privateparams)
end
if settings['cache'] != nil
settings['cache'].each do |folder|
ScmsUtils.log("Publishing: #{folder}(public: caching: 1 year)")
cacheparams = "#{params} --public-read --cache-control='max-age=31449600' \"#{pub}/#{folder}/\" #{settings['bucket']}:#{folder}/"
ScmsUtils.run(cmd, cacheparams)
end
end
ScmsUtils.log("Publishing root (public)")
removeold = ""
removeold = "--delete" if settings['clean'].to_s == "true"
roorparams = "#{removeold} #{params} --public-read \"#{pub}/\" #{settings['bucket']}:/"
ScmsUtils.run(cmd, roorparams)
ScmsUtils.successLog("Deployed :)")
if settings['uri'] != nil
ScmsUtils.log(settings['uri'])
end
end
|