gha_config 0.16 → 0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/CI.yml +0 -25
- data/CHANGELOG.md +9 -0
- data/README.md +39 -0
- 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 +32 -17
- metadata +2 -3
- data/.github/workflow-src +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f38b004057c7f52c5d24ccd7d75d65e323dbc64f57256f472b32e7b5d03a63cf
|
4
|
+
data.tar.gz: c0405f8dcc6adb2457267eaccc6fee2e30d2247f0d4dc0db744f5d82903017ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37a0c649ee04795bc424852b31fef982eac4cadb765e6e87857f3ab546d9a58e746653f068a8211f16345f823f756fb13b05c4c0e5a273207fc4b9ed594d31f9
|
7
|
+
data.tar.gz: 01c6da0bcee2d280badb5deca83cbb51b18f9c402064c3b58ddc0feadce438bf53eed6c2663dc202531e14a61d1be2fa76936e899022cbacc6cd13249873a0eb
|
data/.github/workflows/CI.yml
CHANGED
@@ -41,28 +41,3 @@ jobs:
|
|
41
41
|
run: |
|
42
42
|
sudo chmod 1777 -R /home/circleci/.bundle && bundle config path 'vendor/bundle' && bundle install --jobs=4
|
43
43
|
|
44
|
-
deploy-gem:
|
45
|
-
runs-on: [ubuntu, runner-fleet]
|
46
|
-
needs: [build]
|
47
|
-
container:
|
48
|
-
image: ghcr.io/wishabi/ci-build-environment:ruby-3.0-buster
|
49
|
-
credentials:
|
50
|
-
username: ${{ github.repository_owner }}
|
51
|
-
password: ${{ secrets.GHCR_TOKEN }}
|
52
|
-
if: github.ref == 'refs/heads/main'
|
53
|
-
steps:
|
54
|
-
- name: Checkout code
|
55
|
-
uses: actions/checkout@v2
|
56
|
-
- name: Bundle cache
|
57
|
-
uses: actions/cache@v1
|
58
|
-
with:
|
59
|
-
path: vendor/bundle
|
60
|
-
key: rails-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
61
|
-
restore-keys: rails-{{ arch }}-
|
62
|
-
- name: Bundle install
|
63
|
-
run: |
|
64
|
-
sudo chmod 1777 -R /home/circleci/.bundle && bundle config path 'vendor/bundle' && bundle install --jobs=4
|
65
|
-
- name: Deploy to production
|
66
|
-
run: |
|
67
|
-
chmod +x ./deploy/artifactory.sh && ./deploy/artifactory.sh
|
68
|
-
|
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.20] - 2021-08-09
|
9
|
+
- Added `_variables_` for substitution.
|
10
|
+
|
11
|
+
## [0.19] - 2021-08-06
|
12
|
+
- Add `_options_` for submodules and SSH.
|
13
|
+
|
14
|
+
## [0.17] - 2021-08-04
|
15
|
+
- Adds submodules to checkout action
|
16
|
+
|
8
17
|
## [0.16] - 2021-07-27
|
9
18
|
- Remove dependency on activesupport and byebug
|
10
19
|
- Auto-create directory if it doesn't exist
|
data/README.md
CHANGED
@@ -131,6 +131,45 @@ 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
|
+
|
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.
|
172
|
+
|
134
173
|
## Contributing
|
135
174
|
|
136
175
|
Pull requests are welcome!
|
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
@@ -35,27 +35,38 @@ module GhaConfig
|
|
35
35
|
'runs-on' => '[ubuntu, runner-fleet]'
|
36
36
|
}
|
37
37
|
job['runs-on'] = '[ubuntu, runner-fleet]'
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
flipp_global = {
|
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
|
+
if config.options['enable_ssh']
|
50
|
+
flipp_global['with']['enable_ssh'] = true
|
51
|
+
end
|
52
|
+
job['steps'].unshift(flipp_global)
|
53
|
+
checkout = {
|
54
|
+
'name' => 'Checkout code',
|
55
|
+
'uses' => 'actions/checkout@v2'
|
56
|
+
}
|
57
|
+
if config.options['use_submodules']
|
58
|
+
checkout['with'] = {
|
59
|
+
'token' => "${{ secrets.FLIPPCIRCLECIPULLER_REPO_TOKEN }}",
|
60
|
+
'submodules' => 'recursive'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
job['steps'].unshift(checkout)
|
53
64
|
job['needs'] = "[#{job['needs'].join(', ')}]" if job['needs'].is_a?(Array)
|
54
65
|
new_job.merge!(job)
|
55
66
|
output_hash['jobs'][name] = new_job
|
56
67
|
end
|
57
68
|
output = output_hash.to_yaml
|
58
|
-
output = cleanup(output)
|
69
|
+
output = cleanup(output, config)
|
59
70
|
header = <<-OUT
|
60
71
|
######## GENERATED FROM ./github/workflow-src/CI.yml
|
61
72
|
######## USING gha_config https://github.com/wishabi/gha-config
|
@@ -66,7 +77,7 @@ module GhaConfig
|
|
66
77
|
File.write(output_file, output)
|
67
78
|
end
|
68
79
|
|
69
|
-
def self.cleanup(out)
|
80
|
+
def self.cleanup(out, config)
|
70
81
|
out = out.sub("---\n", '')
|
71
82
|
out = out.gsub(/'on'/, 'on') # replace 'on' with on
|
72
83
|
out = out.gsub(/: ''/, ':') # replace : '' with :
|
@@ -74,6 +85,10 @@ module GhaConfig
|
|
74
85
|
out = out.gsub(/"\[/, '[')
|
75
86
|
out = out.gsub(/\]"/, ']') # change "[...]" to [...]
|
76
87
|
|
88
|
+
config.variables.each do |name, val|
|
89
|
+
out = out.gsub("__#{name}__", val)
|
90
|
+
end
|
91
|
+
|
77
92
|
first, last = out.split("\njobs:")
|
78
93
|
first = first.gsub(/"/, '') # remove quotes from env block
|
79
94
|
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.20'
|
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-
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -32,7 +32,6 @@ executables:
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- ".github/workflow-src"
|
36
35
|
- ".github/workflows/CI.yml"
|
37
36
|
- ".gitignore"
|
38
37
|
- ".rubocop.yml"
|