blob: 1af45923731d3bf91480c0c44839e5974080b467 (
plain)
1
2
3
4
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
|
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
class ReleaseEnvironmentsModel
COMPONENTS = %w[gitaly registry kas mailroom pages gitlab shell].freeze
# Will generate a json object that has a key for every component and a value which is the environment combined with
# short sha
# Example:
# {
# "gitaly": "15-10-stable-c7c5131c",
# "registry": "15-10-stable-c7c5131c",
# "kas": "15-10-stable-c7c5131c",
# "mailroom": "15-10-stable-c7c5131c",
# "pages": "15-10-stable-c7c5131c",
# "gitlab": "15-10-stable-c7c5131c",
# "shell": "15-10-stable-c7c5131c"
# }
def generate_json(environment)
output_json = {}
COMPONENTS.each do |component|
output_json[component.to_s] = "#{environment}-#{ENV['CI_COMMIT_SHORT_SHA']}"
end
JSON.generate(output_json)
end
end
# Outputs in `dotenv` format the ENVIRONMENT and VERSIONS to pass to release environments e.g.
# ENVIRONMENT=15-10-stable
# VERSIONS={"gitaly":"15-10-stable-c7c5131c","registry":"15-10-stable-c7c5131c","kas":"15-10-stable-c7c5131c", ...
if $PROGRAM_NAME == __FILE__
environment = ENV['CI_COMMIT_REF_SLUG'].sub("-ee", "")
puts "ENVIRONMENT=#{environment}"
puts "VERSIONS=#{ReleaseEnvironmentsModel.new.generate_json(environment)}"
end
|