gha_config 0.17 → 0.21
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 +1 -1
- data/README.md +36 -8
- data/lib/gha_config/config.rb +4 -0
- data/lib/gha_config/parser.rb +2 -0
- data/lib/gha_config/version.rb +1 -1
- data/lib/gha_config/writer.rb +38 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fab829ad50d5bd6bc14923bed4ff281f84c6e5d97be1259a6245495877fb1be5
|
4
|
+
data.tar.gz: 23755419b447948a847f540319c8e8d0fb7c32b2c0467e8e567f054168e64456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9c58c07938cfe3a465fba48eb274fb4938eaaeb9d5c89f7b96d2e0df02b7b7ebccb5554764a43c84f77833e3e63e41598d22112dbc655a21397527582cdce5d
|
7
|
+
data.tar.gz: 34ae3c384b458fef9756b04c703fa635ca3d6017fece60ac48105734fa3f4c2aa8a96cecdbc87288feef67f08d7d0a2a0411767f0a72d675620bad7d1744c5bd
|
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.21] - 2021-08-20
|
9
|
+
- Added ARTIFACTORY env variables by default for Scala builds.
|
10
|
+
|
11
|
+
## [0.20] - 2021-08-09
|
12
|
+
- Added `_variables_` for substitution.
|
13
|
+
|
14
|
+
## [0.19] - 2021-08-06
|
15
|
+
- Add `_options_` for submodules and SSH.
|
16
|
+
|
8
17
|
## [0.17] - 2021-08-04
|
9
18
|
- Adds submodules to checkout action
|
10
19
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -131,16 +131,44 @@ 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
|
-
###
|
135
|
-
|
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__
|
136
147
|
```
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
148
|
+
|
149
|
+
will output:
|
150
|
+
|
151
|
+
```yaml
|
152
|
+
on:
|
153
|
+
push:
|
154
|
+
- master
|
155
|
+
- develop
|
142
156
|
```
|
143
|
-
|
157
|
+
|
158
|
+
### Special options
|
159
|
+
|
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:
|
161
|
+
|
162
|
+
```yaml
|
163
|
+
_options_:
|
164
|
+
use_submodules: true
|
165
|
+
enable_ssh: true
|
166
|
+
```
|
167
|
+
|
168
|
+
* `use_submodules`: If this is set it will check out code recursively with submodules. This requires two things:
|
169
|
+
* A secret called `FLIPPCIRCLECIPULLER_REPO_TOKEN` - Eng Cap will need to add this
|
170
|
+
* Your repo needs to have a Git version > 2.18
|
171
|
+
* `enable_ssh`: If set to true, the Flipp global action will have SSH enabled on failures. This should generally only be set to true while debugging things.
|
144
172
|
|
145
173
|
## Contributing
|
146
174
|
|
data/lib/gha_config/config.rb
CHANGED
@@ -3,11 +3,15 @@ module GhaConfig
|
|
3
3
|
attr_accessor :defaults
|
4
4
|
attr_accessor :env
|
5
5
|
attr_accessor :parsed_config
|
6
|
+
attr_accessor :options
|
7
|
+
attr_accessor :variables
|
6
8
|
|
7
9
|
def initialize
|
8
10
|
@env = {}
|
9
11
|
@defaults = []
|
10
12
|
@parsed_config = {}
|
13
|
+
@options = {}
|
14
|
+
@variables = {}
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/gha_config/parser.rb
CHANGED
@@ -6,6 +6,8 @@ module GhaConfig
|
|
6
6
|
hash = YAML.safe_load(input)
|
7
7
|
config = GhaConfig::Config.new
|
8
8
|
config.defaults = hash.delete('_defaults_') || {}
|
9
|
+
config.options = hash.delete('_options_') || {}
|
10
|
+
config.variables = hash.delete('_variables_') || {}
|
9
11
|
config.env = hash.delete('env') || {}
|
10
12
|
|
11
13
|
hash['jobs'] = replace_defaults(config, hash['jobs'])
|
data/lib/gha_config/version.rb
CHANGED
data/lib/gha_config/writer.rb
CHANGED
@@ -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
|
+
})
|
31
35
|
|
32
36
|
output_hash['jobs'] = {}
|
33
37
|
config.parsed_config['jobs'].each do |name, job|
|
@@ -35,30 +39,38 @@ module GhaConfig
|
|
35
39
|
'runs-on' => '[ubuntu, runner-fleet]'
|
36
40
|
}
|
37
41
|
job['runs-on'] = '[ubuntu, runner-fleet]'
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
flipp_global = {
|
43
|
+
'name' => 'Flipp global',
|
44
|
+
'uses' => 'wishabi/github-actions@v0.4',
|
45
|
+
'env' => {
|
46
|
+
'SLACK_BOT_TOKEN' => "${{ secrets.SLACK_BOT_TOKEN }}"
|
47
|
+
},
|
48
|
+
'timeout-minutes' => 10,
|
49
|
+
'with' => {
|
50
|
+
'slack_channel' => '${{env.SLACK_CHANNEL }}',
|
51
|
+
'job_status' => '${{ job.status }}'
|
52
|
+
}}
|
53
|
+
if config.options['enable_ssh']
|
54
|
+
flipp_global['with']['enable_ssh'] = true
|
55
|
+
end
|
56
|
+
job['steps'].unshift(flipp_global)
|
57
|
+
checkout = {
|
58
|
+
'name' => 'Checkout code',
|
59
|
+
'uses' => 'actions/checkout@v2'
|
60
|
+
}
|
61
|
+
if config.options['use_submodules']
|
62
|
+
checkout['with'] = {
|
63
|
+
'token' => "${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN }}",
|
64
|
+
'submodules' => 'recursive'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
job['steps'].unshift(checkout)
|
56
68
|
job['needs'] = "[#{job['needs'].join(', ')}]" if job['needs'].is_a?(Array)
|
57
69
|
new_job.merge!(job)
|
58
70
|
output_hash['jobs'][name] = new_job
|
59
71
|
end
|
60
72
|
output = output_hash.to_yaml
|
61
|
-
output = cleanup(output)
|
73
|
+
output = cleanup(output, config)
|
62
74
|
header = <<-OUT
|
63
75
|
######## GENERATED FROM ./github/workflow-src/CI.yml
|
64
76
|
######## USING gha_config https://github.com/wishabi/gha-config
|
@@ -69,7 +81,7 @@ module GhaConfig
|
|
69
81
|
File.write(output_file, output)
|
70
82
|
end
|
71
83
|
|
72
|
-
def self.cleanup(out)
|
84
|
+
def self.cleanup(out, config)
|
73
85
|
out = out.sub("---\n", '')
|
74
86
|
out = out.gsub(/'on'/, 'on') # replace 'on' with on
|
75
87
|
out = out.gsub(/: ''/, ':') # replace : '' with :
|
@@ -77,6 +89,10 @@ module GhaConfig
|
|
77
89
|
out = out.gsub(/"\[/, '[')
|
78
90
|
out = out.gsub(/\]"/, ']') # change "[...]" to [...]
|
79
91
|
|
92
|
+
config.variables.each do |name, val|
|
93
|
+
out = out.gsub("__#{name}__", val)
|
94
|
+
end
|
95
|
+
|
80
96
|
first, last = out.split("\njobs:")
|
81
97
|
first = first.gsub(/"/, '') # remove quotes from env block
|
82
98
|
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: '0.
|
4
|
+
version: '0.21'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|