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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09d6f4522cd5ee962dab579769563ebe5eb98e41f7183876f8886bc3053a2f9a'
4
- data.tar.gz: e2dbb45afde2fa01072ca64069a51444107173ee3b4bef3c32e5d1ede11e746c
3
+ metadata.gz: fab829ad50d5bd6bc14923bed4ff281f84c6e5d97be1259a6245495877fb1be5
4
+ data.tar.gz: 23755419b447948a847f540319c8e8d0fb7c32b2c0467e8e567f054168e64456
5
5
  SHA512:
6
- metadata.gz: ca61e7d7ac283a1dfd92ba763460f9ca996076d8f4c6811a38da694b7616242cba4d00930fa9b0415b5f1b2b09184b7a1538ecbbd87763024fdaacfc73cca137
7
- data.tar.gz: fdcb23e50ef4d9906f75490d2306061671317c37d7e92b6e75e6d1d53f6fbc3d63e24a6f9067fe74d195c3205af0249f23421f83fc6f3ef4075166b19d0d7370
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gha_config (0.15)
4
+ gha_config (0.20)
5
5
 
6
6
  GEM
7
7
  remote: https://flipplib.jfrog.io/flipplib/api/gems/flipp-gems/
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
- ### Notes on checkout Step
135
- A checkout step is added to every job in the workflow. This looks like below
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
- - name: Checkout code
138
- uses: actions/checkout@v2
139
- with:
140
- token: ${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN || github.token }}
141
- submodules: recursive
148
+
149
+ will output:
150
+
151
+ ```yaml
152
+ on:
153
+ push:
154
+ - master
155
+ - develop
142
156
  ```
143
- The submodules are fetched ONLY by adding the `FLIPPCIRCLECIPULLER_REPO_TOKEN` in github repo secrets.
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
 
@@ -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
@@ -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'])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GhaConfig
4
- VERSION = '0.17'
4
+ VERSION = '0.21'
5
5
  end
@@ -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
- job['steps'].unshift({
39
- 'name' => 'Flipp global',
40
- 'uses' => 'wishabi/github-actions@v0.4',
41
- 'env' => {
42
- 'SLACK_BOT_TOKEN' => "${{ secrets.SLACK_BOT_TOKEN }}"
43
- },
44
- 'timeout-minutes' => 10,
45
- 'with' => {
46
- 'slack_channel' => '${{env.SLACK_CHANNEL }}',
47
- 'job_status' => '${{ job.status }}'
48
- }})
49
- job['steps'].unshift({
50
- 'name' => 'Checkout code',
51
- 'uses' => 'actions/checkout@v2',
52
- 'with' => {
53
- 'token' => "${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN || github.token }}",
54
- 'submodules' => 'recursive'
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.17'
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-05 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop