gha_config 0.19 → 0.23.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +2 -2
- data/README.md +24 -0
- data/lib/gha_config/config.rb +2 -0
- data/lib/gha_config/parser.rb +1 -0
- data/lib/gha_config/version.rb +1 -1
- data/lib/gha_config/writer.rb +24 -14
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a40dd08d619080435933f18a3af9755deb248e9e5b61154363c6c0025d34825
|
4
|
+
data.tar.gz: 92b641b92ef4a8df9abf3f02b516bba5f7e0e5faeb3513076774fbe1b52fb043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13ca7b74a37c167c2d43eec550d10c46e9bc24d996a24cfbdc65bc959a6d237e1c112609a007d5bf5205bbc5a9d8d33bf2161a9bae5f3f08192534c359a84d81
|
7
|
+
data.tar.gz: 388225ab6e85ab7e7c038c8ac0a06179eb0a0bab757e525a0c3367cdcd568ad1466f44e836fa753dc768f064a4a7b177f238873e890e3e18d44132c09f4731ea
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
# [0.22] - 2021-11-16
|
9
|
+
- Fixed so root-level `env` are not overridden by defaults.
|
10
|
+
|
11
|
+
## [0.21] - 2021-08-20
|
12
|
+
- Added ARTIFACTORY env variables by default for Scala builds.
|
13
|
+
|
14
|
+
## [0.20] - 2021-08-09
|
15
|
+
- Added `_variables_` for substitution.
|
16
|
+
|
8
17
|
## [0.19] - 2021-08-06
|
9
18
|
- Add `_options_` for submodules and SSH.
|
10
19
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -131,6 +131,30 @@ Templates get expanded into their contents whenever they are used. Templates can
|
|
131
131
|
|
132
132
|
If you're using Ruby, you can add this gem to your app Gemfile. Otherwise, you can install it locally. Either way, you can re-run it whenever your "source workflow" changes.
|
133
133
|
|
134
|
+
### Variables
|
135
|
+
|
136
|
+
You can define simple variables in a separate section. These variables will be replaced with their values when they appear anywhere in the input workflow file surrounded by *double underscores*. For example:
|
137
|
+
|
138
|
+
```yaml
|
139
|
+
_variables_:
|
140
|
+
PROD_BRANCH: master
|
141
|
+
STAGING_BRANCH: develop
|
142
|
+
|
143
|
+
on:
|
144
|
+
push:
|
145
|
+
- __PROD_BRANCH__
|
146
|
+
- __STAGING_BRANCH__
|
147
|
+
```
|
148
|
+
|
149
|
+
will output:
|
150
|
+
|
151
|
+
```yaml
|
152
|
+
on:
|
153
|
+
push:
|
154
|
+
- master
|
155
|
+
- develop
|
156
|
+
```
|
157
|
+
|
134
158
|
### Special options
|
135
159
|
|
136
160
|
In addition to `_defaults_`, there are other options that will affect how the output of certain steps is emitted. These options are parsed from the `_options_` key:
|
data/lib/gha_config/config.rb
CHANGED
@@ -4,12 +4,14 @@ module GhaConfig
|
|
4
4
|
attr_accessor :env
|
5
5
|
attr_accessor :parsed_config
|
6
6
|
attr_accessor :options
|
7
|
+
attr_accessor :variables
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@env = {}
|
10
11
|
@defaults = []
|
11
12
|
@parsed_config = {}
|
12
13
|
@options = {}
|
14
|
+
@variables = {}
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/gha_config/parser.rb
CHANGED
@@ -7,6 +7,7 @@ module GhaConfig
|
|
7
7
|
config = GhaConfig::Config.new
|
8
8
|
config.defaults = hash.delete('_defaults_') || {}
|
9
9
|
config.options = hash.delete('_options_') || {}
|
10
|
+
config.variables = hash.delete('_variables_') || {}
|
10
11
|
config.env = hash.delete('env') || {}
|
11
12
|
|
12
13
|
hash['jobs'] = replace_defaults(config, hash['jobs'])
|
data/lib/gha_config/version.rb
CHANGED
data/lib/gha_config/writer.rb
CHANGED
@@ -10,7 +10,7 @@ module GhaConfig
|
|
10
10
|
default_env = {
|
11
11
|
'SLACK_CHANNEL' => ''
|
12
12
|
}
|
13
|
-
output_hash['env'] = default_env.
|
13
|
+
output_hash['env'] = default_env.
|
14
14
|
merge({
|
15
15
|
'HOME' => '/home/circleci',
|
16
16
|
'AWS_ACCESS_KEY_ID' => '${{ secrets.AWS_ACCESS_KEY_ID }}',
|
@@ -26,8 +26,12 @@ module GhaConfig
|
|
26
26
|
'SERVICE_NAME' => '${{ secrets.SERVICE_NAME }}',
|
27
27
|
'SERVICE_PROFILE' => '${{ secrets.SERVICE_PROFILE }}',
|
28
28
|
'SERVICE_TOKEN' => '${{ secrets.SERVICE_TOKEN }}',
|
29
|
-
'WISHABI_ENVIRONMENT' => '${{ secrets.WISHABI_ENVIRONMENT }}'
|
30
|
-
|
29
|
+
'WISHABI_ENVIRONMENT' => '${{ secrets.WISHABI_ENVIRONMENT }}',
|
30
|
+
'ARTIFACTORY_HOST' => '${{ secrets.ARTIFACTORY_HOST }}',
|
31
|
+
'ARTIFACTORY_PASSWORD' => '${{ secrets.ARTIFACTORY_PASSWORD }}',
|
32
|
+
'ARTIFACTORY_REALM' => '${{ secrets.ARTIFACTORY_REALM }}',
|
33
|
+
'ARTIFACTORY_USER' => '${{ secrets.ARTIFACTORY_USER }}'
|
34
|
+
}).merge(config.env)
|
31
35
|
|
32
36
|
output_hash['jobs'] = {}
|
33
37
|
config.parsed_config['jobs'].each do |name, job|
|
@@ -50,23 +54,25 @@ module GhaConfig
|
|
50
54
|
flipp_global['with']['enable_ssh'] = true
|
51
55
|
end
|
52
56
|
job['steps'].unshift(flipp_global)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if config.options['use_submodules']
|
58
|
-
checkout['with'] = {
|
59
|
-
'token' => "${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN }}",
|
60
|
-
'submodules' => 'recursive'
|
57
|
+
unless job['steps'].any? { |s| s['uses'] == 'actions/checkout@v2'}
|
58
|
+
checkout = {
|
59
|
+
'name' => 'Checkout code',
|
60
|
+
'uses' => 'actions/checkout@v2'
|
61
61
|
}
|
62
|
+
if config.options['use_submodules']
|
63
|
+
checkout['with'] = {
|
64
|
+
'token' => "${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN }}",
|
65
|
+
'submodules' => 'recursive'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
job['steps'].unshift(checkout)
|
62
69
|
end
|
63
|
-
job['steps'].unshift(checkout)
|
64
70
|
job['needs'] = "[#{job['needs'].join(', ')}]" if job['needs'].is_a?(Array)
|
65
71
|
new_job.merge!(job)
|
66
72
|
output_hash['jobs'][name] = new_job
|
67
73
|
end
|
68
74
|
output = output_hash.to_yaml
|
69
|
-
output = cleanup(output)
|
75
|
+
output = cleanup(output, config)
|
70
76
|
header = <<-OUT
|
71
77
|
######## GENERATED FROM ./github/workflow-src/CI.yml
|
72
78
|
######## USING gha_config https://github.com/wishabi/gha-config
|
@@ -77,7 +83,7 @@ module GhaConfig
|
|
77
83
|
File.write(output_file, output)
|
78
84
|
end
|
79
85
|
|
80
|
-
def self.cleanup(out)
|
86
|
+
def self.cleanup(out, config)
|
81
87
|
out = out.sub("---\n", '')
|
82
88
|
out = out.gsub(/'on'/, 'on') # replace 'on' with on
|
83
89
|
out = out.gsub(/: ''/, ':') # replace : '' with :
|
@@ -85,6 +91,10 @@ module GhaConfig
|
|
85
91
|
out = out.gsub(/"\[/, '[')
|
86
92
|
out = out.gsub(/\]"/, ']') # change "[...]" to [...]
|
87
93
|
|
94
|
+
config.variables.each do |name, val|
|
95
|
+
out = out.gsub("__#{name}__", val)
|
96
|
+
end
|
97
|
+
|
88
98
|
first, last = out.split("\njobs:")
|
89
99
|
first = first.gsub(/"/, '') # remove quotes from env block
|
90
100
|
last = last.gsub(/\n (\S)/) { "\n\n #{$1}" } # add empty line before job keys
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gha_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.23.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -61,9 +61,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '2.3'
|
62
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "
|
64
|
+
- - ">"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 1.3.1
|
67
67
|
requirements: []
|
68
68
|
rubygems_version: 3.2.21
|
69
69
|
signing_key:
|