forked from octokit/octokit.rb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request octokit#1252 from petar-lazarov/action-workflows
Introduce Client methods for Workflows/WorkflowRun
- Loading branch information
Showing
11 changed files
with
284 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
module Octokit | ||
class Client | ||
module ActionsWorkflowRuns | ||
# List all runs for a repository workflow | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param workflow [Integer, String] Id or file name of the workflow | ||
# @option options [String] :actor Optional filtering by a user | ||
# @option options [String] :branch Optional filtering by a branch | ||
# @option options [String] :event Optional filtering by the event type | ||
# @option options [String] :status Optional filtering by a status or conclusion | ||
# | ||
# @return [Sawyer::Resource] the total count and an array of workflows | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs | ||
def workflow_runs(repo, workflow, options = {}) | ||
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options | ||
end | ||
alias list_workflow_runs workflow_runs | ||
|
||
# List all workflow runs for a repository | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @option options [String] :actor Optional filtering by the login of a user | ||
# @option options [String] :branch Optional filtering by a branch | ||
# @option options [String] :event Optional filtering by the event type (e.g. push, pull_request, issue) | ||
# @option options [String] :status Optional filtering by a status or conclusion (e.g. success, completed...) | ||
# | ||
# @return [Sawyer::Resource] the total count and an array of workflows | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs | ||
def repository_workflow_runs(repo, options = {}) | ||
paginate "#{Repository.path repo}/actions/runs", options | ||
end | ||
alias list_repository_workflow_runs repository_workflow_runs | ||
|
||
# Get a workflow run | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param id [Integer] Id of a workflow run | ||
# | ||
# @return [Sawyer::Resource] Run information | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run | ||
def workflow_run(repo, id, options = {}) | ||
get "#{Repository.path repo}/actions/runs/#{id}", options | ||
end | ||
|
||
# Re-runs a workflow run | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param id [Integer] Id of a workflow run | ||
# | ||
# @return [Boolean] Returns true if the re-run request was accepted | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow | ||
def rerun_workflow_run(repo, id, options = {}) | ||
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/rerun", options | ||
end | ||
|
||
# Cancels a workflow run | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param id [Integer] Id of a workflow run | ||
# | ||
# @return [Boolean] Returns true if the cancellation was accepted | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run | ||
def cancel_workflow_run(repo, id, options = {}) | ||
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/cancel", options | ||
end | ||
|
||
# Get a download url for archived log files of a workflow run | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param id [Integer] Id of a workflow run | ||
# | ||
# @return [String] URL to the archived log files of the run | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs | ||
def workflow_run_logs(repo, id, options = {}) | ||
url = "#{Repository.path repo}/actions/runs/#{id}/logs" | ||
|
||
response = client_without_redirects.head(url, options) | ||
response.headers['Location'] | ||
end | ||
|
||
# Delets all log files of a workflow run | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param id [Integer] Id of a workflow run | ||
# | ||
# @return [Boolean] Returns true if the logs are deleted | ||
# @see https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs | ||
def delete_workflow_run_logs(repo, id, options = {}) | ||
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Octokit | ||
class Client | ||
# Methods for the Actions Workflows API | ||
# | ||
# @see https://developer.github.com/v3/actions/workflows | ||
module ActionsWorkflows | ||
|
||
# Get the workflows in a repository | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# | ||
# @return [Sawyer::Resource] the total count and an array of workflows | ||
# @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows | ||
def workflows(repo, options = {}) | ||
paginate "#{Repository.path repo}/actions/workflows", options | ||
end | ||
alias list_workflows workflows | ||
|
||
# Get single workflow in a repository | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A GitHub repository | ||
# @param id [Integer, String] Id or file name of the workflow | ||
# | ||
# @return [Sawyer::Resource] A single workflow | ||
# @see https://developer.github.com/v3/actions/workflows/#get-a-workflow | ||
def workflow(repo, id, options = {}) | ||
get "#{Repository.path repo}/actions/workflows/#{id}", options | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...tionsWorkflowRuns/_repository_workflow_runs/returns_all_workflow_runs_for_repository.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/actions/runs","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.v3+json"],"User-Agent":["Octokit Ruby Gem 4.18.0"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Date":["Wed, 06 May 2020 11:57:16 GMT"],"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Server":["GitHub.com"],"Status":["200 OK"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4987"],"X-Ratelimit-Reset":["1588769530"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP","Accept-Encoding, Accept, X-Requested-With"],"Etag":["W/\"d83cfc16727ae54b8d36f02ffcb63c36\""],"X-Oauth-Scopes":["admin:org, delete_repo, repo, workflow"],"X-Accepted-Oauth-Scopes":[""],"X-Github-Media-Type":["github.v3; format=json"],"Access-Control-Expose-Headers":["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset"],"Access-Control-Allow-Origin":["*"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Frame-Options":["deny"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Referrer-Policy":["origin-when-cross-origin, strict-origin-when-cross-origin"],"Content-Security-Policy":["default-src 'none'"],"X-Github-Request-Id":["8088:2D3E6:478AF0:5478F7:5EB2A61C"]},"body":{"encoding":"ASCII-8BIT","base64_string":"eyJ0b3RhbF9jb3VudCI6MCwid29ya2Zsb3dfcnVucyI6W119\n"},"http_version":null},"recorded_at":"Wed, 06 May 2020 11:57:17 GMT"}],"recorded_with":"VCR 5.1.0"} |
1 change: 1 addition & 0 deletions
1
...assettes/Octokit_Client_ActionsWorkflows/_workflows/returns_the_repository_workflows.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/repos/<GITHUB_LOGIN>/<GITHUB_TEST_REPOSITORY>/actions/workflows","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.v3+json"],"User-Agent":["Octokit Ruby Gem 4.18.0"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Date":["Wed, 06 May 2020 11:57:18 GMT"],"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Server":["GitHub.com"],"Status":["200 OK"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4984"],"X-Ratelimit-Reset":["1588769531"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP","Accept-Encoding, Accept, X-Requested-With"],"Etag":["W/\"125a96a0dec4d32c8419772cfa8f5a32\""],"X-Oauth-Scopes":["admin:org, delete_repo, repo, workflow"],"X-Accepted-Oauth-Scopes":[""],"X-Github-Media-Type":["github.v3; format=json"],"Access-Control-Expose-Headers":["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset"],"Access-Control-Allow-Origin":["*"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Frame-Options":["deny"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Referrer-Policy":["origin-when-cross-origin, strict-origin-when-cross-origin"],"Content-Security-Policy":["default-src 'none'"],"X-Github-Request-Id":["9338:342E:4BA04A:58BDDF:5EB2A61E"]},"body":{"encoding":"ASCII-8BIT","base64_string":"eyJ0b3RhbF9jb3VudCI6MCwid29ya2Zsb3dzIjpbXX0=\n"},"http_version":null},"recorded_at":"Wed, 06 May 2020 11:57:18 GMT"}],"recorded_with":"VCR 5.1.0"} |
Oops, something went wrong.