gha_config 0.11 → 0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +22 -17
- data/lib/gha_config/parser.rb +2 -2
- data/lib/gha_config/version.rb +1 -1
- data/lib/gha_config/writer.rb +15 -1
- 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: 505c781e33f72b50194bcb3537246c35d4ff89d06540cc50d10c75f752e17ddf
|
4
|
+
data.tar.gz: 1c93a1f335b8f699b943cd64fc3ad0e077522155484254c9aa01b3b398ef0fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95100f624513111e5a8b8e7e1079cdb4f3d27a95e9f91137d8648f729e3ee67ff4db46ff333a0d85ac0403b6eff4ae277eaa358fdd10e991eb7008b0d528fe3
|
7
|
+
data.tar.gz: 235c656111d2b7df4bbc78e0f927083d96f784bf087a03f0eee9a7b98f6f56e1214dfd787f6de0bd6011be5d2c1b4afbeda47931202add4819d54730ef9f7bdd
|
data/CHANGELOG.md
CHANGED
@@ -5,5 +5,8 @@ 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.12] - 2021-07-19
|
9
|
+
- Fixes related to global action
|
10
|
+
|
8
11
|
## [0.11] - 2021-07-15
|
9
12
|
- First public version.
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ This gem will process a templated file and output a GitHub Action workflow file
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
You will need Ruby 2.3 or greater to run this (
|
7
|
+
You will need Ruby 2.3 or greater to run this (you can install this via Homebrew if you don't have it). Make sure you have the latest version of Rubygems as well.
|
8
8
|
|
9
9
|
Install using `gem install gha_config`.
|
10
10
|
|
@@ -23,7 +23,7 @@ Template keys are very similar to [YAML anchors](http://blogs.perl.org/users/tin
|
|
23
23
|
|
24
24
|
Template keys all begin and end with underscores: `_`. You define template keys in a special `_defaults_` section in your config, and you can use them elsewhere.
|
25
25
|
|
26
|
-
Here's an example of a templated GitHub Action workflow file
|
26
|
+
Here's an example of a templated GitHub Action workflow file.
|
27
27
|
|
28
28
|
```yaml
|
29
29
|
on:
|
@@ -47,11 +47,8 @@ defaults_:
|
|
47
47
|
key: rails-${{ hashFiles('Gemfile.lock') }}
|
48
48
|
restore-keys: rails-
|
49
49
|
_teardown_:
|
50
|
-
- name:
|
51
|
-
|
52
|
-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
53
|
-
uses: voxmedia/github-action-slack-notify-build@v2
|
54
|
-
if: failure()
|
50
|
+
- name: Cleanup
|
51
|
+
- run: docker cleanup
|
55
52
|
_setup_:
|
56
53
|
- _cache_
|
57
54
|
- name: Bundle install
|
@@ -62,10 +59,13 @@ jobs:
|
|
62
59
|
container: _container_
|
63
60
|
steps:
|
64
61
|
- _setup_
|
62
|
+
- name: Print build
|
63
|
+
run: ls dist/
|
65
64
|
- _teardown_
|
66
65
|
```
|
67
66
|
|
68
|
-
The output of this file will look like this:
|
67
|
+
The output of this file will look like this (you can see that it auto-creates the checkout and "Flipp global" steps):
|
68
|
+
|
69
69
|
```yaml
|
70
70
|
name: CI
|
71
71
|
|
@@ -105,6 +105,14 @@ jobs:
|
|
105
105
|
steps:
|
106
106
|
- name: Checkout code
|
107
107
|
uses: actions/checkout@v2
|
108
|
+
- name: Flipp global
|
109
|
+
uses: wishabi/github-actions@v0.3
|
110
|
+
env:
|
111
|
+
SLACK_BOT_TOKEN: "${{ secrets.SLACK_BOT_TOKEN }}"
|
112
|
+
timeout-minutes: 10
|
113
|
+
with:
|
114
|
+
slack_channel: "${{env.SLACK_CHANNEL }}"
|
115
|
+
job_status: "${{ job.status }}"
|
108
116
|
- name: Bundle cache
|
109
117
|
uses: actions/cache@v2
|
110
118
|
with:
|
@@ -113,18 +121,15 @@ jobs:
|
|
113
121
|
restore-keys: rails-
|
114
122
|
- name: Bundle install
|
115
123
|
run: bundle install --jobs=4
|
116
|
-
- name:
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
if: failure()
|
124
|
+
- name: Print build
|
125
|
+
run: ls dist/
|
126
|
+
- name: Cleanup
|
127
|
+
run: docker cleanup
|
121
128
|
```
|
122
129
|
|
123
|
-
|
124
|
-
|
125
|
-
Templates get expanded into their contents whenever they are used. Templates can also include templates (as you can see that the `setup` template includes the `cache` template). Finally, if a template is used inside a list of steps, the expansion will continue the list rather than nest it.
|
130
|
+
Templates get expanded into their contents whenever they are used. Templates can also include templates (as you can see that the `_setup_` template includes the `_cache_` template). Finally, if a template is used inside a list of steps, the expansion will continue the list rather than nest it.
|
126
131
|
|
127
|
-
|
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.
|
128
133
|
|
129
134
|
## Contributing
|
130
135
|
|
data/lib/gha_config/parser.rb
CHANGED
@@ -17,13 +17,13 @@ module GhaConfig
|
|
17
17
|
|
18
18
|
def self.replace_defaults(config, hash)
|
19
19
|
if hash.is_a?(Array)
|
20
|
-
return hash.map { |v| self.replace_defaults(config, v)}.flatten
|
20
|
+
return hash.map { |v| self.replace_defaults(config, v)}.compact.flatten
|
21
21
|
elsif hash.is_a?(Hash)
|
22
22
|
return hash.map { |k, v| [k, self.replace_defaults(config, v)] }.to_h
|
23
23
|
end
|
24
24
|
return hash unless hash.is_a?(String) && hash =~ /_.*_/
|
25
|
+
return hash unless config.defaults.key?(hash)
|
25
26
|
val = config.defaults[hash]
|
26
|
-
return hash if val.nil?
|
27
27
|
if val.is_a?(Array)
|
28
28
|
val.map { |v| self.replace_defaults(config, v) }.flatten
|
29
29
|
else
|
data/lib/gha_config/version.rb
CHANGED
data/lib/gha_config/writer.rb
CHANGED
@@ -5,7 +5,10 @@ module GhaConfig
|
|
5
5
|
output_hash['name'] = 'CI'
|
6
6
|
output_hash['on'] = config.parsed_config['on']
|
7
7
|
|
8
|
-
|
8
|
+
default_env = {
|
9
|
+
'SLACK_CHANNEL' => ''
|
10
|
+
}
|
11
|
+
output_hash['env'] = default_env.merge(config.env).
|
9
12
|
merge({
|
10
13
|
'HOME' => '/home/circleci',
|
11
14
|
'AWS_ACCESS_KEY_ID' => '${{ secrets.AWS_ACCESS_KEY_ID }}',
|
@@ -30,6 +33,17 @@ module GhaConfig
|
|
30
33
|
'runs-on' => '[ubuntu, runner-fleet]'
|
31
34
|
}
|
32
35
|
job['runs-on'] = '[ubuntu, runner-fleet]'
|
36
|
+
job['steps'].unshift({
|
37
|
+
'name' => 'Flipp global',
|
38
|
+
'uses' => 'wishabi/github-actions@v0.3',
|
39
|
+
'env' => {
|
40
|
+
'SLACK_BOT_TOKEN' => "${{ secrets.SLACK_BOT_TOKEN }}"
|
41
|
+
},
|
42
|
+
'timeout-minutes' => 10,
|
43
|
+
'with' => {
|
44
|
+
'slack_channel' => '${{env.SLACK_CHANNEL }}',
|
45
|
+
'job_status' => '${{ job.status }}'
|
46
|
+
}})
|
33
47
|
job['steps'].unshift({
|
34
48
|
'name' => 'Checkout code',
|
35
49
|
'uses' => 'actions/checkout@v2'
|
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.12'
|
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-07-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|