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.
-
#me ⇒ Hash
Make an API request to get the authenticated user.
Methods inherited from Base
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
.
33 34 35 |
# File 'lib/ci_runner/client/github.rb', line 33 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
.
45 46 47 |
# File 'lib/ci_runner/client/github.rb', line 45 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.
59 60 61 62 63 |
# File 'lib/ci_runner/client/github.rb', line 59 def download_log(repository, check_run_id) download_url = get("/repos/#{repository}/actions/jobs/#{check_run_id}/logs") URI.open(download_url) 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 |