prima-twig 0.31.0 → 0.31.23
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 +4 -4
- data/bin/twig-deploy +5 -5
- data/bin/twig-feature +64 -26
- data/bin/twig-update-ami +134 -0
- data/lib/prima_twig.rb +7 -2
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c36cb4c8176db85c979b1995cad1b2cf1ae02fc3
|
|
4
|
+
data.tar.gz: 2a1120e43e192b7ddc9d887f4d2ffd9e30a70f50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9ebb2212ac29551c503bd6495c0bf89126f44883aa561d5ca764365f53f0d17f59e7d1e69f0926e56fe0a1990a2489e4cc044c4d217bf438d11a5e731047d2c
|
|
7
|
+
data.tar.gz: 486cb677de1114eeb757d608de17485d06df0d257bf7e0f3b7b50596768f5efcf86a6094ae0546058c8a6f001d7752473f4101039a999a7d396cae27fe8d5d75
|
data/bin/twig-deploy
CHANGED
|
@@ -51,7 +51,7 @@ class Review
|
|
|
51
51
|
def initialize
|
|
52
52
|
@prima = Prima.new
|
|
53
53
|
output "Controllo se ci sono aggiornamenti da fare..."
|
|
54
|
-
|
|
54
|
+
exec "gem update prima-twig && twig deploy #{ARGV.join ' '}" unless `gem outdated`.lines.grep(/^prima-twig \(.*\)/).empty?
|
|
55
55
|
@cf = Aws::CloudFormation::Client.new
|
|
56
56
|
@ecs = Aws::ECS::Client.new
|
|
57
57
|
@s3 = Aws::S3::Client.new
|
|
@@ -132,9 +132,9 @@ class Review
|
|
|
132
132
|
mail.html_part = html_part
|
|
133
133
|
mail.text_part = text_part
|
|
134
134
|
|
|
135
|
-
opts = {address: 'smtp.
|
|
136
|
-
opts[:user_name] = '
|
|
137
|
-
opts[:password] = @prima.config['
|
|
135
|
+
opts = {address: 'email-smtp.eu-west-1.amazonaws.com', port: '587'}
|
|
136
|
+
opts[:user_name] = @prima.config['aws_username']
|
|
137
|
+
opts[:password] = @prima.config['aws_password']
|
|
138
138
|
|
|
139
139
|
mail.delivery_method(:smtp, opts)
|
|
140
140
|
mail.deliver
|
|
@@ -216,7 +216,7 @@ class Review
|
|
|
216
216
|
|
|
217
217
|
saves = JSON.parse body
|
|
218
218
|
|
|
219
|
-
save_code = saves.sample[
|
|
219
|
+
save_code = saves.sample['unique_identifier']
|
|
220
220
|
url_garanzie = "https://www.prima.it/preventivo/auto/#{save_code}/garanzie?browserstack=true"
|
|
221
221
|
job_name = get_paparatzinger_job_name(clean_commit_message(job_name))
|
|
222
222
|
|
data/bin/twig-feature
CHANGED
|
@@ -29,6 +29,7 @@ class Release
|
|
|
29
29
|
@import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore2-TaskDefinitionDbRestore-137UJ3IWV3S60:1'
|
|
30
30
|
@dns_record_identifier = nil
|
|
31
31
|
@ecs_cluster_name = nil
|
|
32
|
+
@deploy_update = false
|
|
32
33
|
@projects = {
|
|
33
34
|
'prima' => {},
|
|
34
35
|
'backoffice' => {},
|
|
@@ -54,6 +55,7 @@ class Release
|
|
|
54
55
|
when 'finish'
|
|
55
56
|
finish_feature!
|
|
56
57
|
when 'deploy'
|
|
58
|
+
abort('Non sei nella cartella di artemide') unless Dir.pwd.match 'artemide$'
|
|
57
59
|
if ['terminate', 'stop', 'shutdown', 'halt', 'destroy'].include? args[1]
|
|
58
60
|
deploy_shutdown!
|
|
59
61
|
elsif 'update' == args[1]
|
|
@@ -85,7 +87,7 @@ class Release
|
|
|
85
87
|
|
|
86
88
|
def start_feature!
|
|
87
89
|
branch_name = @prima.clean_branch_name(ask('Inserisci il nome del branch (puoi omettere feature/): '.cyan))
|
|
88
|
-
stop_unless branch_name
|
|
90
|
+
stop_unless !branch_name.empty?, 'Devi inserire il nome del branch'
|
|
89
91
|
branch_name.prepend 'feature/' unless branch_name.include? 'feature'
|
|
90
92
|
|
|
91
93
|
output "Il nome del branch sarà " + branch_name.yellow
|
|
@@ -315,6 +317,8 @@ class Release
|
|
|
315
317
|
output "Deploy update menu"
|
|
316
318
|
`git pull && git submodule init && git submodule update`
|
|
317
319
|
|
|
320
|
+
@deploy_update = true
|
|
321
|
+
|
|
318
322
|
output "Recupero le informazioni sui QA attivi..."
|
|
319
323
|
stack_list, envs = get_stacks()
|
|
320
324
|
|
|
@@ -342,7 +346,6 @@ class Release
|
|
|
342
346
|
@projects[env.key] = select_branch_to_deploy(env.key, env.value)
|
|
343
347
|
end
|
|
344
348
|
end
|
|
345
|
-
|
|
346
349
|
deploy_feature!
|
|
347
350
|
|
|
348
351
|
output "Finito!".green
|
|
@@ -350,7 +353,7 @@ class Release
|
|
|
350
353
|
|
|
351
354
|
def deploy_feature!
|
|
352
355
|
`git pull && git submodule init && git submodule update`
|
|
353
|
-
if
|
|
356
|
+
if deploy_crash?
|
|
354
357
|
deploy_id = Digest::MD5.hexdigest(
|
|
355
358
|
@projects["prima"][:name] +
|
|
356
359
|
@projects["backoffice"][:name] +
|
|
@@ -362,9 +365,9 @@ class Release
|
|
|
362
365
|
@projects["peano"][:name] +
|
|
363
366
|
@projects["rogoreport"][:name] +
|
|
364
367
|
@projects["assange"][:name] +
|
|
365
|
-
@projects["borat"][:name]
|
|
368
|
+
@projects["borat"][:name] +
|
|
369
|
+
@projects['crash'][:name]
|
|
366
370
|
)
|
|
367
|
-
@projects['crash'] = choose_branch_to_deploy('crash', true)
|
|
368
371
|
else
|
|
369
372
|
deploy_id = Digest::MD5.hexdigest(
|
|
370
373
|
@projects["prima"][:name] +
|
|
@@ -377,8 +380,7 @@ class Release
|
|
|
377
380
|
@projects["peano"][:name] +
|
|
378
381
|
@projects["rogoreport"][:name] +
|
|
379
382
|
@projects["assange"][:name] +
|
|
380
|
-
@projects["borat"][:name]
|
|
381
|
-
@projects['crash'][:name]
|
|
383
|
+
@projects["borat"][:name]
|
|
382
384
|
)
|
|
383
385
|
end
|
|
384
386
|
@dns_record_identifier = deploy_id
|
|
@@ -431,12 +433,9 @@ class Release
|
|
|
431
433
|
{
|
|
432
434
|
key: "borat",
|
|
433
435
|
value: @projects["borat"][:name]
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
key: 'crash',
|
|
437
|
-
value: @projects['crash'][:name]
|
|
438
436
|
}
|
|
439
437
|
]
|
|
438
|
+
tags << { key: 'crash', value: @projects['crash'][:name] } if deploy_crash?
|
|
440
439
|
|
|
441
440
|
cluster_stack_name = "ecs-cluster-qa-#{deploy_id}"
|
|
442
441
|
|
|
@@ -489,7 +488,7 @@ class Release
|
|
|
489
488
|
wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db)
|
|
490
489
|
import_dbs(ec2_ip_address(asg_stack_name)) unless stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
|
491
490
|
|
|
492
|
-
import_redis_crash(ec2_ip_address(asg_stack_name))
|
|
491
|
+
import_redis_crash(ec2_ip_address(asg_stack_name)) if deploy_crash? && !stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
|
493
492
|
|
|
494
493
|
wait_for_stack_ready(@stack_name_alb) unless stack_ready?(@stack_name_alb)
|
|
495
494
|
wait_for_stack_ready(@stack_name_alb_ws) unless stack_ready?(@stack_name_alb_ws)
|
|
@@ -610,7 +609,9 @@ class Release
|
|
|
610
609
|
|
|
611
610
|
stack_name_ermes = "ecs-task-ermes-qa-#{deploy_id}"
|
|
612
611
|
git_checkout_version('ermes', @projects["ermes"][:revision])
|
|
613
|
-
stack_body =
|
|
612
|
+
stack_body = YAML.load_file('projects/ermes/deploy/task.yml')
|
|
613
|
+
stack_body['Resources']['ECSServiceErmes']['Properties'].reject!{ |k| ['LoadBalancers', 'Role'].include?(k) }
|
|
614
|
+
stack_body = stack_body.to_yaml
|
|
614
615
|
parameters = [
|
|
615
616
|
{
|
|
616
617
|
parameter_key: "Environment",
|
|
@@ -620,9 +621,25 @@ class Release
|
|
|
620
621
|
parameter_key: "ReleaseVersion",
|
|
621
622
|
parameter_value: @projects["ermes"][:revision]
|
|
622
623
|
},
|
|
624
|
+
{
|
|
625
|
+
parameter_key: "TaskDesiredCount",
|
|
626
|
+
parameter_value: "1"
|
|
627
|
+
},
|
|
623
628
|
{
|
|
624
629
|
parameter_key: "ECSClusterName",
|
|
625
630
|
parameter_value: @ecs_cluster_name
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
parameter_key: "ALBShortName",
|
|
634
|
+
parameter_value: "ermes-qa-#{deploy_id}"[0..31]
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
parameter_key: "HostnamePattern",
|
|
638
|
+
parameter_value: "ermes-#{@dns_record_identifier}.qa.colaster.com"
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
parameter_key: "HostnamePatternPriority",
|
|
642
|
+
parameter_value: hostname_pattern_priority
|
|
626
643
|
}
|
|
627
644
|
]
|
|
628
645
|
if stack_exists?(stack_name_ermes)
|
|
@@ -1053,6 +1070,10 @@ class Release
|
|
|
1053
1070
|
parameter_key: "PeanoIp",
|
|
1054
1071
|
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1055
1072
|
},
|
|
1073
|
+
{
|
|
1074
|
+
parameter_key: "ErmesIp",
|
|
1075
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1076
|
+
},
|
|
1056
1077
|
{
|
|
1057
1078
|
parameter_key: "RedisIp",
|
|
1058
1079
|
parameter_value: ec2_ip_address(asg_stack_name)
|
|
@@ -1077,6 +1098,7 @@ class Release
|
|
|
1077
1098
|
urania_hostname = get_route53_hostname(stack_name_urania)
|
|
1078
1099
|
bburago_hostname = get_route53_hostname(stack_name_bburago)
|
|
1079
1100
|
hal9000_hostname = get_route53_hostname(stack_name_hal9000)
|
|
1101
|
+
ermes_hostname = get_route53_hostname(stack_name_ermes)
|
|
1080
1102
|
fidaty_hostname = get_route53_hostname(stack_name_fidaty)
|
|
1081
1103
|
peano_hostname = get_route53_hostname(stack_name_peano)
|
|
1082
1104
|
backoffice_hostname = get_route53_hostname(stack_name_backoffice)
|
|
@@ -1086,7 +1108,7 @@ class Release
|
|
|
1086
1108
|
|
|
1087
1109
|
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
|
1088
1110
|
|
|
1089
|
-
launch_marley
|
|
1111
|
+
launch_marley ec2_ip_address(asg_stack_name), prima_hostname, borat_hostname
|
|
1090
1112
|
|
|
1091
1113
|
projects_text = "
|
|
1092
1114
|
> Prima url: https://#{prima_hostname}
|
|
@@ -1094,6 +1116,7 @@ class Release
|
|
|
1094
1116
|
> Backoffice (Borat) url: https://#{borat_hostname}
|
|
1095
1117
|
> Urania url: http://#{urania_hostname}:81
|
|
1096
1118
|
> Bburago url: http://#{bburago_hostname}:83
|
|
1119
|
+
> Ermes url: http://#{ermes_hostname}:10002
|
|
1097
1120
|
> Hal9000 url: http://#{hal9000_hostname}:10031
|
|
1098
1121
|
> Fidaty url: http://#{fidaty_hostname}:10021
|
|
1099
1122
|
> Peano url: http://#{peano_hostname}:10039
|
|
@@ -1129,6 +1152,8 @@ class Release
|
|
|
1129
1152
|
host = "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
1130
1153
|
when stack_name.include?('crash')
|
|
1131
1154
|
host = "crash-#{@dns_record_identifier}.qa.colaster.com"
|
|
1155
|
+
when stack_name.include?('ermes')
|
|
1156
|
+
host = "ermes-#{@dns_record_identifier}.qa.colaster.com"
|
|
1132
1157
|
end
|
|
1133
1158
|
host
|
|
1134
1159
|
end
|
|
@@ -1265,6 +1290,7 @@ class Release
|
|
|
1265
1290
|
"docker run -v $PWD:/code -w /code -e MIX_ENV=qa --entrypoint /bin/sh ermes_web \
|
|
1266
1291
|
'-c' 'mix local.hex --force && mix hex.info && \
|
|
1267
1292
|
mix deps.get && mix compile && mix deps.compile && \
|
|
1293
|
+
mix phx.digest && \
|
|
1268
1294
|
rm -rf _build/qa/rel/ && \
|
|
1269
1295
|
mix release --env=qa'"
|
|
1270
1296
|
].each do |cmd|
|
|
@@ -1278,7 +1304,7 @@ class Release
|
|
|
1278
1304
|
end
|
|
1279
1305
|
|
|
1280
1306
|
def deploy_crash?
|
|
1281
|
-
!@projects['crash'][:default_branch]
|
|
1307
|
+
!@projects['crash'].empty? && !@projects['crash'][:default_branch]
|
|
1282
1308
|
end
|
|
1283
1309
|
|
|
1284
1310
|
def create_crash_artifact(revision, deploy_id)
|
|
@@ -1294,7 +1320,7 @@ class Release
|
|
|
1294
1320
|
crash_qa_host = get_route53_hostname(stack_name_crash)
|
|
1295
1321
|
|
|
1296
1322
|
ws_endpoint = "wss://#{crash_qa_host}/socket/websocket?vsn=1.0.0"
|
|
1297
|
-
frontend_endpoint = "https://#{crash_qa_host}/"
|
|
1323
|
+
frontend_endpoint = "https://#{crash_qa_host}/graphql"
|
|
1298
1324
|
|
|
1299
1325
|
[
|
|
1300
1326
|
'docker-compose build web',
|
|
@@ -1312,7 +1338,8 @@ class Release
|
|
|
1312
1338
|
mix phx.digest && \
|
|
1313
1339
|
mix deps.clean --all && \
|
|
1314
1340
|
mix deps.get && \
|
|
1315
|
-
mix compile && mix release --env=qa'"
|
|
1341
|
+
mix compile && mix release --env=qa'",
|
|
1342
|
+
'docker-compose down'
|
|
1316
1343
|
].each do |cmd|
|
|
1317
1344
|
execute_command cmd
|
|
1318
1345
|
end
|
|
@@ -1359,7 +1386,7 @@ class Release
|
|
|
1359
1386
|
"docker run -v $PWD:/code -w /code -e MIX_ENV=qa --entrypoint /bin/sh hal9000_web \
|
|
1360
1387
|
'-c' 'mix local.hex --force && mix hex.info && \
|
|
1361
1388
|
mix deps.get && mix compile && mix deps.compile && \
|
|
1362
|
-
mix
|
|
1389
|
+
mix phx.digest && \
|
|
1363
1390
|
rm -rf _build/qa/rel/ && \
|
|
1364
1391
|
mix release --env=qa'"
|
|
1365
1392
|
].each do |cmd|
|
|
@@ -1392,7 +1419,7 @@ class Release
|
|
|
1392
1419
|
sed -i \"s/peano-qa-host/#{peano_qa_host}/g\" config/qa.exs && \
|
|
1393
1420
|
mix local.hex --force && mix hex.info && \
|
|
1394
1421
|
mix deps.get && mix compile && mix deps.compile && \
|
|
1395
|
-
mix
|
|
1422
|
+
mix phx.digest && \
|
|
1396
1423
|
rm -rf _build/qa/rel/ && \
|
|
1397
1424
|
mix release --env=qa'"
|
|
1398
1425
|
].each do |cmd|
|
|
@@ -1595,7 +1622,7 @@ class Release
|
|
|
1595
1622
|
assange_qa_host = get_route53_hostname("ecs-task-assange-qa-notneeded")
|
|
1596
1623
|
|
|
1597
1624
|
[
|
|
1598
|
-
"bin/local_build_artifact.sh #{branch_name} #{web_qa_host} #{backoffice_qa_host} #{assange_qa_host} #{deploy_id}"
|
|
1625
|
+
"bin/local_build_artifact.sh #{branch_name} #{web_qa_host} #{backoffice_qa_host} #{assange_qa_host} #{deploy_id} #{'update' if @deploy_update}"
|
|
1599
1626
|
].each do |cmd|
|
|
1600
1627
|
execute_command cmd
|
|
1601
1628
|
end
|
|
@@ -1702,6 +1729,7 @@ class Release
|
|
|
1702
1729
|
end
|
|
1703
1730
|
|
|
1704
1731
|
def choose_branch_to_deploy(project_name, select_master = false)
|
|
1732
|
+
return {} if project_name == 'crash' && select_master
|
|
1705
1733
|
Dir.chdir "projects/#{project_name}"
|
|
1706
1734
|
output "Recupero la lista dei branch del progetto #{project_name}..."
|
|
1707
1735
|
out = %x[ git fetch ]
|
|
@@ -1743,7 +1771,7 @@ class Release
|
|
|
1743
1771
|
Dir.chdir "projects/#{project_name}"
|
|
1744
1772
|
output "Recupero il branch #{project_name}:#{branch_name} ..."
|
|
1745
1773
|
out = %x[ git fetch ]
|
|
1746
|
-
branch_name = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
|
1774
|
+
branch_name = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname) %(committeremail)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
|
1747
1775
|
.split("\n").delete_if { |b| !b.include?(branch_name) }[0..49]
|
|
1748
1776
|
.first
|
|
1749
1777
|
|
|
@@ -1751,8 +1779,8 @@ class Release
|
|
|
1751
1779
|
|
|
1752
1780
|
name = branch_name.split(' ')[0]
|
|
1753
1781
|
revision = branch_name.split(' ')[1]
|
|
1754
|
-
|
|
1755
|
-
{ name: name, revision: revision[0..14] }
|
|
1782
|
+
committer_email = branch_name.split(' ')[2].tr('<>', '')
|
|
1783
|
+
{ name: name, revision: revision[0..14], committer: committer_email }
|
|
1756
1784
|
end
|
|
1757
1785
|
|
|
1758
1786
|
def is_branch_compatible_with_current_twig_version?(project)
|
|
@@ -1777,6 +1805,8 @@ class Release
|
|
|
1777
1805
|
File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
|
|
1778
1806
|
when project == 'crash'
|
|
1779
1807
|
File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
|
|
1808
|
+
when project == 'ermes'
|
|
1809
|
+
File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
|
|
1780
1810
|
end
|
|
1781
1811
|
end
|
|
1782
1812
|
|
|
@@ -1786,7 +1816,7 @@ class Release
|
|
|
1786
1816
|
stack_list.each do |stack|
|
|
1787
1817
|
unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
|
|
1788
1818
|
env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
|
|
1789
|
-
envs[env_hash] = stack.tags unless envs.has_key?(env_hash)
|
|
1819
|
+
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
|
1790
1820
|
end
|
|
1791
1821
|
end
|
|
1792
1822
|
return stack_list, envs
|
|
@@ -1796,7 +1826,7 @@ class Release
|
|
|
1796
1826
|
(Time.now.to_i.to_s[-4..-1].to_i + Random.rand(40000)).to_s
|
|
1797
1827
|
end
|
|
1798
1828
|
|
|
1799
|
-
def launch_marley
|
|
1829
|
+
def launch_marley(ip_address, prima_hostname, borat_hostname)
|
|
1800
1830
|
resp = @cf.describe_stack_resource({
|
|
1801
1831
|
stack_name: 'batch-job-marley',
|
|
1802
1832
|
logical_resource_id: 'JobDefinition'
|
|
@@ -1810,11 +1840,19 @@ class Release
|
|
|
1810
1840
|
environment: [
|
|
1811
1841
|
{
|
|
1812
1842
|
name: 'PRIMA_URL',
|
|
1813
|
-
value: "https://#{
|
|
1843
|
+
value: "https://#{prima_hostname}/"
|
|
1844
|
+
},
|
|
1845
|
+
{
|
|
1846
|
+
name: 'PRIMA_IP',
|
|
1847
|
+
value: ip_address
|
|
1814
1848
|
},
|
|
1815
1849
|
{
|
|
1816
1850
|
name: 'PROJECTS_JSON',
|
|
1817
1851
|
value: @projects.to_json
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
name: 'BACKOFFICE_URL',
|
|
1855
|
+
value: "https://#{borat_hostname}"
|
|
1818
1856
|
}
|
|
1819
1857
|
]
|
|
1820
1858
|
}
|
data/bin/twig-update-ami
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require_relative '../lib/prima_twig.rb'
|
|
5
|
+
require_relative '../lib/prima_aws_client.rb'
|
|
6
|
+
require 'launchy'
|
|
7
|
+
require 'json'
|
|
8
|
+
require 'aws-sdk'
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
class TwigUpdateAmi
|
|
12
|
+
include Command
|
|
13
|
+
include PrimaAwsClient
|
|
14
|
+
def initialize
|
|
15
|
+
output 'Controllo se ci sono aggiornamenti da fare...'
|
|
16
|
+
exec "gem update prima-twig && twig update-ami #{ARGV.join ' '}" unless `gem outdated`.lines.grep(/^prima-twig \(.*\)/).empty?
|
|
17
|
+
@s3 = Aws::S3::Client.new
|
|
18
|
+
@s3_bucket = 'prima-deploy'
|
|
19
|
+
@instances = JSON.parse File.read('../twig-binaries/cloudformation.json')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def execute!(args)
|
|
23
|
+
update_amis args[0], args[1], args[2]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def update_amis(ami_id, ami_name, ami_description)
|
|
29
|
+
@instances['stacks'].each do |instance|
|
|
30
|
+
output 'updating instance definition'.light_green
|
|
31
|
+
Dir.chdir 'ami'
|
|
32
|
+
update_instance_name(ami_id, ami_name, ami_description, instance['json'])
|
|
33
|
+
output 'running packer update (this could take some time)'.light_green
|
|
34
|
+
new_ami_id = update_packer instance['json']
|
|
35
|
+
Dir.chdir '..'
|
|
36
|
+
output 'new ami id: ' + new_ami_id
|
|
37
|
+
instance['stacks'].each do |stack|
|
|
38
|
+
output 'updating ' + stack['yaml_filename'] + ' and copying onto s3'
|
|
39
|
+
update_yml_files(new_ami_id, stack['yaml_filename'])
|
|
40
|
+
copy_yml_files_to_s3(stack['yaml_filename'], stack['s3_key'])
|
|
41
|
+
output 'updating stack on cloudformation'
|
|
42
|
+
update_stack_url(stack['stack_name'], stack['template_url'], stack['parameters']) if stack['stack_name']
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def update_instance_name(ami_id, ami_name, ami_description, ecs_json_path)
|
|
48
|
+
ecs_json = JSON.parse File.read(ecs_json_path)
|
|
49
|
+
|
|
50
|
+
ecs_json['builders'][0]['source_ami'] = ami_id
|
|
51
|
+
ecs_json['builders'][0]['ami_name'] = ami_name
|
|
52
|
+
ecs_json['builders'][0]['ami_description'] = ami_description
|
|
53
|
+
|
|
54
|
+
File.open ecs_json_path, 'w' do |f|
|
|
55
|
+
f.write(JSON.pretty_generate(ecs_json))
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def update_packer(json_filename)
|
|
60
|
+
execute_command "packer build -machine-readable ./#{json_filename} | tee build.log"
|
|
61
|
+
`grep 'artifact,0,id' build.log | cut -d, -f6 | cut -d: -f2`.sub(/\n/, '')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def update_yml_files(ami_id, yaml_filename)
|
|
65
|
+
file_content = File.read yaml_filename
|
|
66
|
+
|
|
67
|
+
file_content.sub!(/ami-[0-9a-z]{8}/, ami_id)
|
|
68
|
+
|
|
69
|
+
File.open yaml_filename, 'w' do |f|
|
|
70
|
+
f.write file_content
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if yaml_filename.include? 'spotfleet'
|
|
74
|
+
old_handle = (File.read yaml_filename)[/InstanceReadyWaitHandleUpdate[0-9]+/]
|
|
75
|
+
if old_handle
|
|
76
|
+
handle_version = old_handle.sub('InstanceReadyWaitHandleUpdate', '').to_i + 1
|
|
77
|
+
|
|
78
|
+
old_condition = (File.read yaml_filename)[/InstanceReadyWaitConditionUpdate[0-9]+/]
|
|
79
|
+
condition_version = old_condition.sub('InstanceReadyWaitConditionUpdate', '').to_i + 1
|
|
80
|
+
|
|
81
|
+
file_content = File.read yaml_filename
|
|
82
|
+
file_content.gsub!(old_handle, 'InstanceReadyWaitHandleUpdate' + handle_version.to_s)
|
|
83
|
+
file_content.gsub!(old_condition, 'InstanceReadyWaitConditionUpdate' + condition_version.to_s)
|
|
84
|
+
|
|
85
|
+
File.open yaml_filename, 'w' do |f|
|
|
86
|
+
f.write file_content
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def copy_yml_files_to_s3(source, s3_key)
|
|
93
|
+
body = File.read source
|
|
94
|
+
@s3.put_object(
|
|
95
|
+
body: body,
|
|
96
|
+
bucket: @s3_bucket,
|
|
97
|
+
key: s3_key
|
|
98
|
+
)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def help_content
|
|
102
|
+
<<-HELP
|
|
103
|
+
|
|
104
|
+
twig-update-ami
|
|
105
|
+
===========
|
|
106
|
+
|
|
107
|
+
Updates ami version and applies it to stacks on cloudformation
|
|
108
|
+
|
|
109
|
+
Synopsis
|
|
110
|
+
--------
|
|
111
|
+
|
|
112
|
+
twig-update-ami
|
|
113
|
+
|
|
114
|
+
Description
|
|
115
|
+
-----------
|
|
116
|
+
|
|
117
|
+
from artemide main folder run
|
|
118
|
+
`twig-update-ami ${AMI_ID} ${AMI_NAME} ${AMI_DESCRIPTION}`
|
|
119
|
+
|
|
120
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
|
121
|
+
Author: Eugenio Laghi <https://github.com/eugeniolaghi>
|
|
122
|
+
|
|
123
|
+
HELP
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
args = ARGV.dup
|
|
127
|
+
|
|
128
|
+
if args.include?('--help')
|
|
129
|
+
puts help_content
|
|
130
|
+
exit
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
TwigUpdateAmi.new.execute!(args)
|
|
134
|
+
end
|
data/lib/prima_twig.rb
CHANGED
|
@@ -13,7 +13,7 @@ class Prima
|
|
|
13
13
|
LABEL_HOTFIX='hotfix'
|
|
14
14
|
LABEL_NEXT_RELEASE='next release'
|
|
15
15
|
LABEL_IN_STAGING='in staging'
|
|
16
|
-
CONFIG_KEYS=['github', 'mandrill', 'sparkpost', 'cloudflare_email', 'cloudflare_apikey']
|
|
16
|
+
CONFIG_KEYS=['github', 'mandrill', 'sparkpost', 'cloudflare_email', 'cloudflare_apikey', 'aws_username', 'aws_password']
|
|
17
17
|
attr_reader :gh, :twig, :config, :rugged, :aws
|
|
18
18
|
|
|
19
19
|
def initialize
|
|
@@ -212,7 +212,12 @@ class Prima
|
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
def assign_issue_to_me(issue)
|
|
215
|
-
|
|
215
|
+
detailed_issue = get_issue issue
|
|
216
|
+
assignees = [user_login]
|
|
217
|
+
detailed_issue.assignees.each do |assignee|
|
|
218
|
+
assignees << assignee.login
|
|
219
|
+
end
|
|
220
|
+
@gh.update_issue('primait/board', issue, :assignees => assignees)
|
|
216
221
|
end
|
|
217
222
|
|
|
218
223
|
def assign_pull_request_to_me(pr_number)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prima-twig
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.31.
|
|
4
|
+
version: 0.31.23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matteo Giachino
|
|
@@ -13,7 +13,7 @@ authors:
|
|
|
13
13
|
autorequire:
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
|
-
date: 2017-
|
|
16
|
+
date: 2017-12-15 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: aws-sdk
|
|
@@ -179,6 +179,7 @@ executables:
|
|
|
179
179
|
- twig-open-pr
|
|
180
180
|
- twig-pick-issue
|
|
181
181
|
- twig-review
|
|
182
|
+
- twig-update-ami
|
|
182
183
|
extensions: []
|
|
183
184
|
extra_rdoc_files: []
|
|
184
185
|
files:
|
|
@@ -189,6 +190,7 @@ files:
|
|
|
189
190
|
- bin/twig-open-pr
|
|
190
191
|
- bin/twig-pick-issue
|
|
191
192
|
- bin/twig-review
|
|
193
|
+
- bin/twig-update-ami
|
|
192
194
|
- lib/command.rb
|
|
193
195
|
- lib/prima_aws_client.rb
|
|
194
196
|
- lib/prima_twig.rb
|