-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.rb
executable file
·41 lines (31 loc) · 1.33 KB
/
build.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
# Generate a GitHub Action with separate builds for every image
# based on the contents of the two target files
require "date"
require "erb"
require "fileutils"
@images = []
["linux", "alpine"].each do |target|
File.open(target).each do |line|
base,tag = line.split
@images.append [base, tag ? tag : base, target]
end
end
# Matrix builds require a least one item in the matrix to be valid
# so we grab the first entry to populate the matrix.
# Everything else is used as explicitly included jobs.
@seed = @images.shift
# Generate the dev.yml
templatename = File.join("_templates", "dev.yml.erb")
renderer = ERB.new(File.read(templatename))
File.open(".github/workflows/dev.yml", "w") { |file| file.puts renderer.result() }
# We need to write a file to trigger the image build action, as just changing the
# contents of workflow doesn't trigger it
File.open(".generated", "w") { |file| file.puts DateTime.now.iso8601 }
# Generate the build.yml
templatename = File.join("_templates", "build.yml.erb")
renderer = ERB.new(File.read(templatename))
File.open(".github/workflows/build.yml", "w") { |file| file.puts renderer.result() }
# We need to write a file to trigger the image build action, as just changing the
# contents of workflow doesn't trigger it
File.open(".generated", "w") { |file| file.puts DateTime.now.iso8601 }