Creating missing repositories
This commit is contained in:
@@ -26,9 +26,10 @@ module Pipeline
|
||||
|
||||
def self.scratch
|
||||
track_slug = "rust"
|
||||
repo_url = "https://github.com/exercism/#{track_slug}-analyzer"
|
||||
repo = Pipeline::AnalyzerRepo.new(repo_url)
|
||||
puts repo.tags
|
||||
repo = Pipeline::AnalyzerRepo.for_track(track_slug)
|
||||
latest_tag = repo.tags.keys.last
|
||||
puts latest_tag
|
||||
AnalyzerBuild.(latest_tag, track_slug)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -21,8 +21,14 @@ class Pipeline::AnalyzerRepo
|
||||
end
|
||||
|
||||
def checkout(ref)
|
||||
ref_pointer = repo.checkout(ref)
|
||||
return ref_pointer.target.target.oid
|
||||
if tags[ref]
|
||||
oid = tags[ref]
|
||||
repo.checkout(oid)
|
||||
return oid
|
||||
else
|
||||
ref_pointer = repo.checkout(ref)
|
||||
return ref_pointer.target.target.oid
|
||||
end
|
||||
end
|
||||
|
||||
def workdir
|
||||
@@ -52,10 +58,6 @@ class Pipeline::AnalyzerRepo
|
||||
raise
|
||||
end
|
||||
|
||||
def main_branch_ref
|
||||
"origin/master"
|
||||
end
|
||||
|
||||
def repo_dir_exists?
|
||||
File.directory?(repo_dir)
|
||||
end
|
||||
|
||||
@@ -6,14 +6,31 @@ class Pipeline::PublishImage
|
||||
def call
|
||||
puts "PUBLISHING #{image_tag}"
|
||||
puts "Login to repo"
|
||||
create_repository
|
||||
login_to_repository
|
||||
tag_build
|
||||
push_build
|
||||
logout
|
||||
end
|
||||
|
||||
def create_repository
|
||||
puts "Checking if repository exists"
|
||||
begin
|
||||
ecr.describe_repositories({
|
||||
repository_names: [image_name]
|
||||
})
|
||||
return
|
||||
rescue Aws::ECR::Errors::RepositoryNotFoundException
|
||||
puts "Repository #{image_name} not found"
|
||||
end
|
||||
puts "Creating repository"
|
||||
ecr.create_repository({
|
||||
repository_name: image_name,
|
||||
image_tag_mutability: "MUTABLE"
|
||||
})
|
||||
end
|
||||
|
||||
def login_to_repository
|
||||
ecr = Aws::ECR::Client.new(region: 'eu-west-1')
|
||||
authorization_token = ecr.get_authorization_token.authorization_data[0].authorization_token
|
||||
plain = Base64.decode64(authorization_token)
|
||||
user,password = plain.split(":")
|
||||
@@ -52,4 +69,9 @@ class Pipeline::PublishImage
|
||||
Pipeline.config["registry_endpoint"]
|
||||
end
|
||||
|
||||
memoize
|
||||
def ecr
|
||||
Aws::ECR::Client.new(region: 'eu-west-1')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user