From de98ad53cc70b6975e1c5207df0c284fa6c6ed76 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Thu, 9 Mar 2023 09:17:24 +0100 Subject: [PATCH] github_packages: additional retry of skopeo copy with backoff --- Library/Homebrew/github_packages.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index f0e8541847..c08fae7d5d 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -412,7 +412,16 @@ class GitHubPackages puts "#{skopeo} #{args.join(" ")} --dest-creds=#{user}:$HOMEBREW_GITHUB_PACKAGES_TOKEN" else args << "--dest-creds=#{user}:#{token}" - system_command!(skopeo, verbose: true, print_stdout: true, args: args) + retry_count = 0 + begin + system_command!(skopeo, verbose: true, print_stdout: true, args: args) + rescue ErrorDuringExecution + retry_count += 1 + odie "Cannot perform an upload to registry after retrying multiple times!" if retry_count >= 5 + sleep 5*retry_count + retry + end + package_name = "#{GitHubPackages.repo_without_prefix(repo)}/#{image_name}" ohai "Uploaded to https://github.com/orgs/#{org}/packages/container/package/#{package_name}" end