Last active
August 12, 2020 16:42
-
-
Save gmcculloug/feca1b673be1c7e8400adb9dd1f5806c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup | |
app_name = ENV['OPENSHIFT_BUILD_NAME'].split('-')[0..-3].join('-') || ENV['APP_NAME'] | |
raise 'Missing ENV variable APP_NAME' unless app_name | |
@product_component = "#{app_name}:api" | |
# Prefix defined at https://pp.engineering.redhat.com/pp/ | |
@prefix = case app_name | |
when /catalog/, /approval/ then 'services-automation-services-catalog' | |
when /sources/ then 'services-sources' | |
when /topological/ then 'services-topoinv' | |
else | |
raise "Prefix not defined for APP_NAME: [#{app_name}]" | |
end | |
end | |
def dockerfile | |
dockerfile = File.join(Dir.pwd, 'Dockerfile') | |
if File.exist?(dockerfile) | |
File.read(dockerfile) =~ /FROM (.*)/ | |
puts File.join(@prefix, @product_component, "Dockerfile-FROM-#{$1}") | |
end | |
end | |
def ruby_rpm_build_info | |
puts File.join(@prefix, @product_component, %x<rpm -qa --qf='%{sourcerpm}\n' | sort -u | sed 's/\.src\.rpm$//' | grep ruby>) | |
end | |
def ruby_gems | |
require 'bundler' | |
bundle = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile)) | |
bundle.specs.map { |spec| puts File.join(@prefix, @product_component, "rubygem-#{spec.name}:#{spec.version}") } | |
end | |
setup | |
dockerfile | |
ruby_rpm_build_info | |
ruby_gems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment