dropbox-deployment 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dropbox-deployment +6 -6
- data/lib/dropbox-deployment.rb +82 -73
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa6f4afecf0d6b17a9b7084128a8683609ae98d
|
4
|
+
data.tar.gz: 0b0396ae2791268c3cd3f5c58546e52df9080250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ced33980d89c1f6c3a05cfcc6032abe9663d569ddc1572f5ae7c2173b98632d26107f613b64f36c35bce30844797e244576147b02366412ca3aa5d922d608e6
|
7
|
+
data.tar.gz: 8f9a34afb6cf620c9662c0105e25a1a22a8ee14b4a4f9567afed5cac3d7758ede8c02e4e21f9517204541d2c6c960e42f9e64c2b97a527d8c7aff8227e8147e9
|
data/bin/dropbox-deployment
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'dropbox-deployment'
|
4
|
-
|
5
|
-
deployer = DropboxDeployment::Deployer.new
|
6
|
-
deployer.deploy
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'dropbox-deployment'
|
4
|
+
|
5
|
+
deployer = DropboxDeployment::Deployer.new
|
6
|
+
deployer.deploy
|
data/lib/dropbox-deployment.rb
CHANGED
@@ -1,73 +1,82 @@
|
|
1
|
-
require 'dropbox_api'
|
2
|
-
require 'yaml'
|
3
|
-
require 'logger'
|
4
|
-
require 'find'
|
5
|
-
require 'dotenv'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@@logger
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@@logger.debug("
|
71
|
-
|
72
|
-
|
73
|
-
|
1
|
+
require 'dropbox_api'
|
2
|
+
require 'yaml'
|
3
|
+
require 'logger'
|
4
|
+
require 'find'
|
5
|
+
require 'dotenv'
|
6
|
+
require 'pathname'
|
7
|
+
Dotenv.load
|
8
|
+
|
9
|
+
module DropboxDeployment
|
10
|
+
class Deployer
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@@logger = Logger.new(STDOUT)
|
14
|
+
@@logger.level = Logger::WARN
|
15
|
+
end
|
16
|
+
|
17
|
+
def uploadFile(dropboxClient, file, dropboxPath)
|
18
|
+
fileName = File.basename(file)
|
19
|
+
content = IO.read(file)
|
20
|
+
@@logger.debug("Uploading " + fileName + " to " + dropboxPath + "/" + fileName)
|
21
|
+
dropboxClient.upload dropboxPath + "/" + fileName, content, :mode => :overwrite
|
22
|
+
end
|
23
|
+
|
24
|
+
def uploadDirectory(dropboxClient, directoryPath, dropboxPath)
|
25
|
+
Find.find(directoryPath) do |file|
|
26
|
+
|
27
|
+
if !File.directory?(file)
|
28
|
+
currentFileDir = File.dirname(file)
|
29
|
+
if currentFileDir == directoryPath
|
30
|
+
modifedPath = dropboxPath
|
31
|
+
else
|
32
|
+
# adjust for if we are a subdirectory within the desired saved build folder
|
33
|
+
modifedPath = dropboxPath + "/" + Pathname.new(currentFileDir).relative_path_from(Pathname.new(directoryPath)).to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
uploadFile(dropboxClient, file, modifedPath)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def deploy()
|
42
|
+
# Validation
|
43
|
+
if !File.file?("dropbox-deployment.yml")
|
44
|
+
puts "\nNo config file found. You need a file called `dropbox-deployment.yml` with the configuration. See the README for details\n\n"
|
45
|
+
exit(1)
|
46
|
+
end
|
47
|
+
config = YAML.load_file("dropbox-deployment.yml")
|
48
|
+
testing = false
|
49
|
+
if !config.has_key?("deploy")
|
50
|
+
puts "\nError in config file! Build file must contain a `deploy` object.\n\n"
|
51
|
+
exit(1)
|
52
|
+
end
|
53
|
+
artifactPath = config["deploy"]["artifacts_path"]
|
54
|
+
dropboxPath = config["deploy"]["dropbox_path"]
|
55
|
+
|
56
|
+
if ENV["DROPBOX_OAUTH_BEARER"].nil?
|
57
|
+
puts "\nYou must have an environment variable of `DROPBOX_OAUTH_BEARER` in order to deploy to Dropbox\n\n"
|
58
|
+
exit(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
if config["deploy"]["debug"]
|
62
|
+
@@logger.level = Logger::DEBUG
|
63
|
+
@@logger.debug("We are in debug mode")
|
64
|
+
end
|
65
|
+
|
66
|
+
dropboxClient = DropboxApi::Client.new
|
67
|
+
|
68
|
+
# Upload all files
|
69
|
+
@@logger.debug("Artifact Path: " + artifactPath)
|
70
|
+
@@logger.debug("Dropbox Path: " + dropboxPath)
|
71
|
+
isDirectory = File.directory?(artifactPath)
|
72
|
+
@@logger.debug("Is directory: " + "#{isDirectory}")
|
73
|
+
if isDirectory
|
74
|
+
uploadDirectory(dropboxClient, artifactPath, dropboxPath)
|
75
|
+
else
|
76
|
+
artifactFile = File.open(artifactPath)
|
77
|
+
uploadFile(dropboxClient, artifactFile, dropboxPath)
|
78
|
+
end
|
79
|
+
@@logger.debug("Uploading complete")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropbox-deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Carlson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox_api
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.6.
|
78
|
+
rubygems_version: 2.6.11
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Deploy your CI artifacts to Dropbox
|