deis_deploy_redant 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +53 -0
- data/lib/deis_deploy_redant/configuration.rb +15 -0
- data/lib/deis_deploy_redant/initializer.rb +5 -0
- data/lib/deis_deploy_redant/railtie.rb +12 -0
- data/lib/deis_deploy_redant.rb +25 -0
- data/lib/tasks/deis.rake +60 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cf48822738c9d4f9626f9d5f466efa288df8f589
|
4
|
+
data.tar.gz: 6bb09027fd34960522d4d8ce4cfaf6daf0a48cb2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82357639ced4a40844ca7b91efa734043f2c8512eacf64407e811018db38c815dd72a4b1b4b14ef9b4f17ab2717dd0e9a0dbfda069b3327c48dd4b2fa04dc737
|
7
|
+
data.tar.gz: 942caac7ef5799fed7ac03b79f9cdef9a12dea20179fbc953d12cc05750efcbc46f50e019dd019c46bad9cc86c3379c57e689c7123f242a4ed9febe00c4ccfa8
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
Deis Deploy Ruby
|
2
|
+
================
|
3
|
+
|
4
|
+
This gem allows you to deploy and notify your deploy to the Red Ant Deis cluster.
|
5
|
+
|
6
|
+
If you're not a developer at Red Ant this gem will not be immediately useful but may be a nice starting point for Deis deploy notifications.
|
7
|
+
|
8
|
+
Pre-requisites
|
9
|
+
--------------
|
10
|
+
|
11
|
+
* `deis` executable signed in to the Red Ant deis cluster
|
12
|
+
* permissions on the deis app your're trying to deploy
|
13
|
+
* a valid git remote to your deis app, defaults to a git remote called 'deis'
|
14
|
+
* the app created in the [deis-billing portal](https://billing.k8s.redant.com.au)
|
15
|
+
|
16
|
+
Setup
|
17
|
+
-----
|
18
|
+
|
19
|
+
In your `Gemfile`
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'deis_deploy_redant', :group => 'development'
|
23
|
+
```
|
24
|
+
|
25
|
+
Create an initialiser to configure the gem
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# config/initializers/deis_deploy.rb
|
29
|
+
|
30
|
+
DeisDeployRedant.configure do |config|
|
31
|
+
config.billing_app_url = 'http://example.com' # checkout the Deis playbook for the url
|
32
|
+
config.deploy_message_merges = true
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
To deploy
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ bundle exec rails deis:deploy[REMOTE_NAME]
|
40
|
+
```
|
41
|
+
|
42
|
+
Or to notify without pushing a new deploy
|
43
|
+
|
44
|
+
```bash
|
45
|
+
$ bundle exec rails deis:notify[REMOTE_NAME]
|
46
|
+
```
|
47
|
+
|
48
|
+
Tests
|
49
|
+
-----
|
50
|
+
|
51
|
+
```bash
|
52
|
+
$ rspec
|
53
|
+
```
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DeisDeployRedant
|
2
|
+
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :remote_name
|
5
|
+
attr_accessor :billing_app_url
|
6
|
+
attr_accessor :deploy_message_merges
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@remote_name = 'deis'
|
10
|
+
@billing_app_url = ''
|
11
|
+
@deploy_message_merges = true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'deis_deploy_redant/configuration'
|
4
|
+
require 'deis_deploy_redant/railtie' if defined?(Rails)
|
5
|
+
|
6
|
+
module DeisDeployRedant
|
7
|
+
class << self
|
8
|
+
attr_writer :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configuration
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
|
19
|
+
class Deploy
|
20
|
+
def remote_name
|
21
|
+
DeisDeployRedant.configuration.remote_name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/tasks/deis.rake
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
namespace :deis do
|
7
|
+
|
8
|
+
desc 'Deploy an app to deis and report the deploy to deis-billing'
|
9
|
+
task :deploy, [:git_remote] => [:environment] do |t, args|
|
10
|
+
git_remote = args.git_remote || 'deis'
|
11
|
+
|
12
|
+
check_billing_app_url!
|
13
|
+
|
14
|
+
current_git_branch = `git symbolic-ref --short HEAD`.delete("\n")
|
15
|
+
|
16
|
+
if system("git push #{git_remote} #{current_git_branch}:master")
|
17
|
+
report_deis_deploy(git_remote)
|
18
|
+
else
|
19
|
+
puts "\n\n *** Deploy failed ***\n\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Report a deploy to deis-billing'
|
24
|
+
task :report, [:git_remote] => [:environment] do |t, args|
|
25
|
+
check_billing_app_url!
|
26
|
+
report_deis_deploy(args.git_remote)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def report_deis_deploy(git_remote)
|
31
|
+
remote_path = `git remote get-url #{git_remote}`
|
32
|
+
app_name = /2222\/(?<deis_app>.+?)\.git/.match(remote_path)[:deis_app]
|
33
|
+
deploy_user = /You are (?<username>.+?) /.match(`deis whoami`)
|
34
|
+
previous_git_sha = HTTParty.get("#{DeisDeployRedant.configuration.billing_app_url}#{app_name}").parsed_response
|
35
|
+
current_git_sha = `git rev-parse HEAD`
|
36
|
+
|
37
|
+
deploy_message = ''
|
38
|
+
if previous_git_sha.empty?
|
39
|
+
deploy_message = 'Initial commit, see github for full change list'
|
40
|
+
elsif DeisDeployRedant.configuration.deploy_message_merges
|
41
|
+
# Get merges between releases
|
42
|
+
deploy_message = `git log --merges --format="* %b" #{previous_git_sha}..HEAD`
|
43
|
+
else
|
44
|
+
# Get commits between releases
|
45
|
+
deploy_message = `git log --format="* %s" #{previous_git_sha}..HEAD`
|
46
|
+
end
|
47
|
+
|
48
|
+
HTTParty.post(
|
49
|
+
"#{DeisDeployRedant.configuration.billing_app_url}#{app_name}/report-deploy",
|
50
|
+
:body => JSON.dump({
|
51
|
+
:git_sha => current_git_sha,
|
52
|
+
:user => deploy_user,
|
53
|
+
:deploy_message => deploy_message
|
54
|
+
})
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_billing_app_url!
|
59
|
+
raise StandardError, 'Must set billing_app_url in DeisDeployRedant initializer' if DeisDeployRedant.configuration.billing_app_url.empty?
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deis_deploy_redant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Davies
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.1'
|
55
|
+
description: Automates the process of pushing a new release and sending a deploy notification
|
56
|
+
to the billing api
|
57
|
+
email: thomas@redant.com.au
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- README.md
|
63
|
+
- lib/deis_deploy_redant.rb
|
64
|
+
- lib/deis_deploy_redant/configuration.rb
|
65
|
+
- lib/deis_deploy_redant/initializer.rb
|
66
|
+
- lib/deis_deploy_redant/railtie.rb
|
67
|
+
- lib/tasks/deis.rake
|
68
|
+
homepage: https://github.com/red-ant/deis-deploy-ruby
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.5.1
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Deploy apps to the Red Ant Deis cluster and notify deployments
|
92
|
+
test_files: []
|