8000 pre-deploy hook: sample file fails to work because it parses git remotes incorrectly · Issue #1538 · basecamp/kamal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
pre-deploy hook: sample file fails to work because it parses git remotes incorrectly #1538
Closed
@miguno

Description

@miguno

TL;DR: The sample file for the pre-deploy hook (https://github.com/basecamp/kamal/blob/main/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample) passes the wrong GitHub repo string to Octokit.

Expected behavior

When I test-drive the pre-deploy hook in a local checkout of a public GitHub repository, then it should correctly check the build status.

$ git config --get remote.origin.url
https://github.com/basecamp/kamal.git

$ KAMAL_DESTINATION=production ruby pre-deploy.sample
Checking build status...
Build not started...
Build not started...
Build not started...
[...snip...]

Actual behavior

$ git config --get remote.origin.url
https://github.com/basecamp/kamal.git

$ KAMAL_DESTINATION=production ruby pre-deploy.sample
Checking build status...
Build status could not be found
$
# exit code is 1

The problem is that Octokit requires a different format for the GH repo in this call:

  def refresh!
    @combined_status = github_client.combined_status(remote_url, git_sha)
  end

The current pre-deploy hook incorrectly passes basecamp/kamal.git instead of basecamp/kamal (no .git suffix).

A related problem is that the current pre-deploy hook only understands https://github.com/... remotes, but not git@github.com: remotes:

$ git config --get remote.origin.url
git@github.com:basecamp/kamal.git # <== see here

$ KAMAL_DESTINATION=production ruby pre-deploy.sample
Checking build status...
/Users/miguno/.local/share/mise/installs/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/octokit-10.0.0/lib/octokit/repository.rb:99:in 'Octokit::Repository#raise_invalid_repository!': "git@github.com:miguno/sauber.git" is invalid as a repository identifier. Use the user/repo (String) format, or the repository ID (Integer), or a hash containing :repo and :user keys. (Octokit::InvalidRepository)

      raise Octokit::InvalidRepository, msg
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /Users/miguno/.local/share/mise/installs/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/octokit-10.0.0/lib/octokit/repository.rb:36:in 'Octokit::Repository#initialize'
        from /Users/miguno/.local/share/mise/installs/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/octokit-10.0.0/lib/octokit/repository.rb:59:in 'Class#new'
        from /Users/miguno/.local/share/mise/installs/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/octokit-10.0.0/lib/octokit/repository.rb:59:in 'Octokit::Repository.path'
        from /Users/miguno/.local/share/mise/installs/ruby/3.4.3/lib/ruby/gems/3.4.0/gems/octokit-10.0.0/lib/octokit/client/statuses.rb:27:in 'Octokit::Client::Statuses#combined_status'
        from pre-deploy:53:in 'GithubStatusChecks#refresh!'
        from pre-deploy:49:in 'GithubStatusChecks#initialize'
        from pre-deploy:89:in 'Class#new'
        from pre-deploy:89:in '<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0