-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.rb
executable file
·48 lines (41 loc) · 1.01 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
42
43
44
45
46
47
48
#! /usr/bin/env ruby
#
# This script generates Tekton Tasks for the currently supported
# set of Snyk images. The Actions all have the same interface.
#
require "erb"
require 'fileutils'
@variants = [
"DotNet",
"Golang",
"Gradle",
"Maven",
"Node",
"PHP",
"Python",
"Ruby",
"Scala",
"Swift",
]
templatename = File.join("_templates", "BASE.md.erb")
renderer = ERB.new(File.read(templatename))
File.open("README.md", "w") { |file| file.puts renderer.result() }
@variants.each do | variant |
puts "Generating Task for #{variant}"
dirname = variant.downcase
unless File.directory?(dirname)
FileUtils.mkdir_p(dirname)
end
@variant = variant
{
"task.yaml.erb" => "#{variant.downcase}.yaml",
"README.md.erb" => "README.md"
}.each do |template, output|
templatename = File.join("_templates", template)
renderer = ERB.new(File.read(templatename))
filename = File.join(dirname, output)
File.open(filename, "w") { |file|
file.puts renderer.result()
}
end
end