diff --git a/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample b/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample index 665197f1..05b3055b 100755 --- a/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample +++ b/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample @@ -43,7 +43,7 @@ class GithubStatusChecks attr_reader :remote_url, :git_sha, :github_client, :combined_status def initialize - @remote_url = `git config --get remote.origin.url`.strip.delete_prefix("https://github.com/") + @remote_url = github_repo_from_remote_url @git_sha = `git rev-parse HEAD`.strip @github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"]) refresh! @@ -77,6 +77,18 @@ class GithubStatusChecks "Build not started..." end end + + private + def github_repo_from_remote_url + url = `git config --get remote.origin.url`.strip.delete_suffix(".git") + if url.start_with?("https://github.com/") + url.delete_prefix("https://github.com/") + elsif url.start_with?("git@github.com:") + url.delete_prefix("git@github.com:") + else + url + end + end end