Class: CIRunner::Client::Github
- Defined in:
- lib/ci_runner/client/github.rb
Overview
A simple client to interact the GitHub API.
Constant Summary collapse
- API_ENDPOINT =
"api.github.com"
Instance Method Summary collapse
-
#check_runs(repository, commit) ⇒ Hash
Makes an API request to get the CI checks for the
commit
. -
#commit_statuses(repository, commit) ⇒ Hash
Makes an API request to get the Commit statuses for the
commit
. -
#download_log(repository, check_run_id) ⇒ Tempfile, IO
Makes two requests to get the CI log for a check run.
-
#latest_release(repository) ⇒ Hash
Get the latest release of a repository.
-
#me ⇒ Hash
Make an API request to get the authenticated user.
Methods inherited from Base
default_client, #initialize, #reset!
Constructor Details
This class inherits a constructor from CIRunner::Client::Base
Instance Method Details
#check_runs(repository, commit) ⇒ Hash
Makes an API request to get the CI checks for the commit
.
44 45 46 |
# File 'lib/ci_runner/client/github.rb', line 44 def check_runs(repository, commit) get("/repos/#{repository}/commits/#{commit}/check-runs") end |
#commit_statuses(repository, commit) ⇒ Hash
Makes an API request to get the Commit statuses for the commit
.
56 57 58 |
# File 'lib/ci_runner/client/github.rb', line 56 def commit_statuses(repository, commit) get("/repos/#{repository}/commits/#{commit}/statuses") end |
#download_log(repository, check_run_id) ⇒ Tempfile, IO
Makes two requests to get the CI log for a check run. The first request returns a 302 containing a Location header poiting to a short lived url to download the log. The second request is to actually download the log.
70 71 72 73 74 |
# File 'lib/ci_runner/client/github.rb', line 70 def download_log(repository, check_run_id) download_url = get("/repos/#{repository}/actions/jobs/#{check_run_id}/logs") URI.open(download_url) end |
#latest_release(repository) ⇒ Hash
Get the latest release of a repository.
docs.github.com/en/rest/releases/releases#get-the-latest-release
32 33 34 |
# File 'lib/ci_runner/client/github.rb', line 32 def latest_release(repository) get("/repos/#{repository}/releases/latest") end |
#me ⇒ Hash
Make an API request to get the authenticated user. Used to verify if the access token the user has stored in its config is valid.
21 22 23 |
# File 'lib/ci_runner/client/github.rb', line 21 def me get("/user") end |