padma-deployment 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/tasks/deployment.rake +36 -21
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWUxODg3NWZiZjExNjEzMDU4M2MzOTMxMWY5YTM3NTljYTUzNTkyZA==
4
+ ZmZiOGJmOTc1YTIyMTgwOWI0MGUxNjQyN2JjZWI1YWY2MDhmYzFkZQ==
5
5
  data.tar.gz: !binary |-
6
- NTE2YTQyZmJlY2EzM2RlMDc4YzQ5MjZhNThkNGU4YWE0NjUyNTY5OQ==
6
+ NDkzN2QzZDFmZmU2YjZjNDk5NGFiNDdiNzUxYTI3ZDg2ZDNlZjI2YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDc3OWRkNWEzNDE5ZGVjMjEwMDU1NzU0NmZmZDA3MDk0OTBiNjdiYTk3Zjdk
10
- Yjg2Njg0Y2YyOWU0OGUyMzAyOWFjMTUyOTFlZmQ5NDM4MzI1YTIyOTU4NWFi
11
- OTMzNDc1N2UxMTY1Nzk2MjZmZGFjZDU2YTBkYmEwMDJiNmU1YTc=
9
+ NGZkYThlMzdiYWU5MGY4OTE5NWQxODBkZDUyZDUzZjRhMTAxNTE3YzRlZjc0
10
+ MTYyYWZjMTBiMDZhOWZmOGZhOTFkNjcwMjE3OTliNTBlODBmYTNlYTU0YmIx
11
+ ZDg3MDkxZTIwNTIxODlmZjEwYWI4ZmJlODFjMDdkYTY3MjhlOTk=
12
12
  data.tar.gz: !binary |-
13
- MWRhZjcxMTBiZWI4OWZmNDhlMmI3NWMxNWVkYmZjZTQ2MTc0NzY0NmIzMjBk
14
- NmJmMjU5MzE4MzliMmE5NmJmMzRiNDA0NDhiYjJkMmM4M2YxMzdmZDQyMGU3
15
- YmFlYTQ4YTVhOTNkZDU5NzUyMGVhMWExODMyNTU4NTE0ZWJhZDg=
13
+ OTgyYmQ4NTI3MWU1OGM4MjBiYzlmYmEzNmVlYTY1ZjQxYjU5MTQ0YzQ5NjQw
14
+ ODgxZjZhMGIzMjI5ZWNiODg1NjU2NDA1MGU1MDQ5NDU3ZWY4OTczMmMxOGNm
15
+ ODQ3NzM4YWE3YTE5MmFiNDYzN2I3ODM0ODFiOTlhZTk3ZTE3NjE=
@@ -1,46 +1,61 @@
1
+ require "#{Rails.root}/config/deployment_configuration"
2
+
1
3
  # TODO see rugged gem for a better implementation of ruby commands
2
4
  namespace :deploy do
3
5
 
6
+ task :test_configuration do
7
+ puts PADMA_DEPLOYMENT.inspect
8
+ end
9
+
4
10
  desc "deploys to staging server"
5
11
  task :staging do
6
12
  puts "====> deploying to staging..."
7
-
8
13
  `git checkout master`
9
14
  `git pull`
10
- `git fetch`
11
- if local_branch_exists?('staging')
12
- `git checkout staging`
13
- `git rebase master`
14
- else
15
- `git checkout -b staging`
16
- end
17
- `git push staging staging:master --force`
18
- `git push origin staging:staging --force`
15
+ rebase_to_master('staging')
16
+ deploy(:staging)
19
17
  `git checkout master`
20
18
  end
21
19
 
22
20
  desc "deploys to production server"
23
21
  task :production do
24
- puts "updating origin/production..."
22
+ puts "====> deploying to production..."
25
23
  `git checkout master`
26
24
  `git pull`
27
- `git fetch`
28
- if local_branch_exists?('production')
29
- `git checkout production`
30
- `git rebase master`
31
- else
32
- `git checkout -b production`
33
- end
34
- `git rebase master`
35
- `git push origin production:production`
25
+ rebase_to_master('production')
26
+ deploy(:production)
36
27
  `git checkout master`
37
- puts "you can ssh to serve to deploy"
38
28
  end
39
29
 
40
30
  end
41
31
 
32
+ def rebase_to_master(branch_name)
33
+ if local_branch_exists?(branch_name)
34
+ `git checkout #{branch_name}`
35
+ `git rebase master`
36
+ else
37
+ `git checkout -b #{branch_name}`
38
+ end
39
+ end
40
+
42
41
  # @return [Boolean]
43
42
  def local_branch_exists?(branch_name)
44
43
  `git show-ref --verify --quiet refs/heads/#{branch_name}`
45
44
  $?.success?
46
45
  end
46
+
47
+ def deploy(environment)
48
+ server = PADMA_DEPLOYMENT[environment][:server] || (environment==:staging)? :heroku : :ec2
49
+ remote = PADMA_DEPLOYMENT[environment][:remote_name] || environment
50
+ if PADMA_DEPLOYMENT[environment][:force_push]
51
+ force = "--force"
52
+ end
53
+ case server
54
+ when :heroku
55
+ `git push #{remote} #{environment}:master #{force}`
56
+ `git push origin #{environment}:#{environment} #{force}`
57
+ when :ec2
58
+ `git push origin #{environment}:#{environment} #{force}`
59
+ puts "you can ssh to server to deploy"
60
+ end
61
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padma-deployment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dwayne Macgowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-16 00:00:00.000000000 Z
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties