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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/gha_config/writer.rb', line 5
def self.write(config, output_file)
output_hash = {}
output_hash['name'] = 'CI'
output_hash['on'] = config.parsed_config['on']
default_env = {
'SLACK_CHANNEL' => ''
}
output_hash['env'] = default_env.
merge({
'HOME' => '/home/circleci',
'AWS_ACCESS_KEY_ID' => '${{ secrets.AWS_ACCESS_KEY_ID }}',
'AWS_ACCOUNT_ID' => '${{ secrets.AWS_ACCOUNT_ID }}',
'AWS_REGION' => '${{ secrets.AWS_REGION }}',
'AWS_SECRET_ACCESS_KEY' => '${{ secrets.AWS_SECRET_ACCESS_KEY }}',
'DEPLOYMENT_TYPE' => '${{ secrets.DEPLOYMENT_TYPE }}',
'ECR_REPOSITORY' => '${{ secrets.ECR_REPOSITORY }}',
'ECS_CLUSTER_PROD' => '${{ secrets.ECS_CLUSTER_PROD }}',
'ECS_CLUSTER_STG' => '${{ secrets.ECS_CLUSTER_STG }}',
'ECS_SERVICE_PROD' => '${{ secrets.ECS_SERVICE_PROD }}',
'ECS_SERVICE_STG' => '${{ secrets.ECS_SERVICE_STG }}',
'SERVICE_NAME' => '${{ secrets.SERVICE_NAME }}',
'SERVICE_PROFILE' => '${{ secrets.SERVICE_PROFILE }}',
'SERVICE_TOKEN' => '${{ secrets.SERVICE_TOKEN }}',
'WISHABI_ENVIRONMENT' => '${{ secrets.WISHABI_ENVIRONMENT }}',
'ARTIFACTORY_HOST' => '${{ secrets.ARTIFACTORY_HOST }}',
'ARTIFACTORY_PASSWORD' => '${{ secrets.ARTIFACTORY_PASSWORD }}',
'ARTIFACTORY_REALM' => '${{ secrets.ARTIFACTORY_REALM }}',
'ARTIFACTORY_USER' => '${{ secrets.ARTIFACTORY_USER }}'
}).merge(config.env)
output_hash['jobs'] = {}
config.parsed_config['jobs'].each do |name, job|
new_job = {
'runs-on' => '[ubuntu, runner-fleet]'
}
job['runs-on'] = '[ubuntu, runner-fleet]'
flipp_global = {
'name' => 'Flipp global',
'uses' => 'wishabi/[email protected]',
'env' => {
'SLACK_BOT_TOKEN' => "${{ secrets.SLACK_BOT_TOKEN }}"
},
'timeout-minutes' => 10,
'with' => {
'slack_channel' => '${{env.SLACK_CHANNEL }}',
'job_status' => '${{ job.status }}'
}}
if config.options['enable_ssh']
flipp_global['with']['enable_ssh'] = true
end
job['steps'].unshift(flipp_global)
unless job['steps'].any? { |s| s['uses'] == 'actions/checkout@v2'}
checkout = {
'name' => 'Checkout code',
'uses' => 'actions/checkout@v2'
}
if config.options['use_submodules']
checkout['with'] = {
'token' => "${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN }}",
'submodules' => 'recursive'
}
end
job['steps'].unshift(checkout)
end
job['needs'] = "[#{job['needs'].join(', ')}]" if job['needs'].is_a?(Array)
new_job.merge!(job)
output_hash['jobs'][name] = new_job
end
output = output_hash.to_yaml
output = cleanup(output, config)
= <<-OUT
######## GENERATED FROM ./github/workflow-src/CI.yml
######## USING gha_config https://github.com/wishabi/gha-config
OUT
output = + output
FileUtils.mkdir_p(File.dirname(output_file))
File.write(output_file, output)
end
|