Skip to content

Commit

Permalink
refactor: use single template for distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
thisislawatts committed Jan 7, 2025
1 parent 4452496 commit 6d9bda8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 72 deletions.
63 changes: 0 additions & 63 deletions _templates/build.yml.erb

This file was deleted.

6 changes: 3 additions & 3 deletions _templates/distribution-channel.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
base:
- <%= @seed[0] %>
tag:
- <%= @seed[1] %>-<%= @distribution_channel %>
- <%= @seed[1] %>
target:
- <%= @seed[2] %>
include:<% @images.each do |base,tag,target| %>
- base: <%= base %>
tag: <%= tag %>-<%= @distribution_channel %>
tag: <%= tag %>
target: <%= target %><% end %>
steps:
- uses: actions/checkout@v3
Expand All @@ -50,7 +50,7 @@ jobs:
target: ${{ matrix.target }}
repository: snyk/snyk
tags: ${{ matrix.tag }}
build_args: IMAGE=${{ matrix.base }},TAG=${{ matrix.tag }},CLI_VERSION=${{ env.CLI_VERSION }}
build_args: IMAGE=${{ matrix.base }},TAG=${{ matrix.tag }}<%= @post_fix %>,CLI_VERSION=${{ env.CLI_VERSION }}
docs:
runs-on: ubuntu-latest
steps:
Expand Down
20 changes: 14 additions & 6 deletions build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,25 @@
# 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() }

# Generate workflows for the other distribution channels
["preview", "rc"].each do |distribution|
# Available distributions of snyk
# https://docs.snyk.io/snyk-cli/releases-and-channels-for-the-snyk-cli
distribution_map = {
"stable" => "",
"preview" => "-preview",
"rc" => "-rc"
}


# Generate workflows for each distribution channel
distribution_map.each do |distribution, post_fix|
@distribution_channel = distribution
@post_fix = post_fix

# Generate the workflow .yml
templatename = File.join("_templates", "distribution-channel.yml.erb")
renderer = ERB.new(File.read(templatename))

File.open(".github/workflows/" + distribution + ".yml", "w") { |file| file.puts renderer.result() }
end

Expand Down

0 comments on commit 6d9bda8

Please sign in to comment.