octokit 4.6.2 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +239 -118
- data/Rakefile +12 -12
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +59 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +222 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +31 -34
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +25 -20
- data/lib/octokit/client/deployments.rb +25 -5
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +55 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +7 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +60 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +4 -7
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -10
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +238 -61
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +50 -70
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +58 -46
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +32 -19
- data/lib/octokit/client/releases.rb +14 -13
- data/lib/octokit/client/repositories.rb +195 -54
- data/lib/octokit/client/repository_invitations.rb +4 -11
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +8 -13
- data/lib/octokit/client/stats.rb +12 -9
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +106 -25
- data/lib/octokit/client.rb +66 -17
- data/lib/octokit/configurable.rb +42 -30
- data/lib/octokit/connection.rb +43 -21
- data/lib/octokit/default.rb +63 -34
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +5 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +17 -16
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +33 -33
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +107 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/middleware/follow_redirects.rb +17 -13
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +27 -25
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +5 -3
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +13 -10
- metadata +55 -22
- data/lib/octokit/client/authorizations.rb +0 -244
- data/lib/octokit/preview.rb +0 -35
data/Rakefile
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler'
|
2
4
|
Bundler::GemHelper.install_tasks
|
3
5
|
|
4
6
|
require 'rspec/core/rake_task'
|
5
7
|
RSpec::Core::RakeTask.new(:spec)
|
6
8
|
|
7
|
-
task :
|
8
|
-
task :
|
9
|
+
task test: :spec
|
10
|
+
task default: :spec
|
9
11
|
|
10
12
|
namespace :doc do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
]
|
19
|
-
end
|
20
|
-
rescue LoadError
|
13
|
+
require 'yard'
|
14
|
+
YARD::Rake::YardocTask.new do |task|
|
15
|
+
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
|
16
|
+
task.options = [
|
17
|
+
'--output-dir', 'doc/yard',
|
18
|
+
'--markup', 'markdown'
|
19
|
+
]
|
21
20
|
end
|
21
|
+
rescue LoadError
|
22
22
|
end
|
data/lib/ext/sawyer/relation.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sawyer'
|
2
4
|
|
3
5
|
patch = Module.new do
|
4
|
-
def href(options=nil)
|
6
|
+
def href(options = nil)
|
5
7
|
# Temporary workaround for: https://github.com/octokit/octokit.rb/issues/727
|
6
|
-
name.to_s ==
|
8
|
+
name.to_s == 'ssh' ? @href : super
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
data/lib/octokit/arguments.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Octokit
|
3
4
|
# Extracts options from method arguments
|
4
5
|
# @private
|
5
6
|
class Arguments < Array
|
@@ -9,6 +10,5 @@ module Octokit
|
|
9
10
|
@options = args.last.is_a?(::Hash) ? args.pop : {}
|
10
11
|
super(args)
|
11
12
|
end
|
12
|
-
|
13
13
|
end
|
14
14
|
end
|
@@ -1,7 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Octokit
|
3
4
|
# Authentication methods for {Octokit::Client}
|
4
5
|
module Authentication
|
6
|
+
# In Faraday 2.x, the authorization middleware uses new interface
|
7
|
+
FARADAY_BASIC_AUTH_KEYS =
|
8
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
9
|
+
%i[authorization basic]
|
10
|
+
else
|
11
|
+
[:basic_auth]
|
12
|
+
end
|
5
13
|
|
6
14
|
# Indicates if the client was supplied Basic Auth
|
7
15
|
# username and password
|
@@ -21,6 +29,14 @@ module Octokit
|
|
21
29
|
!!@access_token
|
22
30
|
end
|
23
31
|
|
32
|
+
# Indicates if the client was supplied a bearer token
|
33
|
+
#
|
34
|
+
# @see https://developer.github.com/early-access/integrations/authentication/#as-an-integration
|
35
|
+
# @return [Boolean]
|
36
|
+
def bearer_authenticated?
|
37
|
+
!!@bearer_token
|
38
|
+
end
|
39
|
+
|
24
40
|
# Indicates if the client was supplied an OAuth
|
25
41
|
# access token or Basic Auth username and password
|
26
42
|
#
|
@@ -35,22 +51,13 @@ module Octokit
|
|
35
51
|
# requests at a higher rate limit
|
36
52
|
#
|
37
53
|
# @see https://developer.github.com/v3/#unauthenticated-rate-limited-requests
|
38
|
-
# @return Boolean
|
54
|
+
# @return [Boolean]
|
39
55
|
def application_authenticated?
|
40
|
-
!!
|
56
|
+
!!(@client_id && @client_secret)
|
41
57
|
end
|
42
58
|
|
43
59
|
private
|
44
60
|
|
45
|
-
def application_authentication
|
46
|
-
if @client_id && @client_secret
|
47
|
-
{
|
48
|
-
:client_id => @client_id,
|
49
|
-
:client_secret => @client_secret
|
50
|
-
}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
61
|
def login_from_netrc
|
55
62
|
return unless netrc?
|
56
63
|
|
@@ -67,8 +74,7 @@ module Octokit
|
|
67
74
|
self.password = creds.shift
|
68
75
|
end
|
69
76
|
rescue LoadError
|
70
|
-
octokit_warn
|
77
|
+
octokit_warn 'Please install netrc gem for .netrc support'
|
71
78
|
end
|
72
|
-
|
73
79
|
end
|
74
80
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Actions Artifacts API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/actions/artifacts
|
8
|
+
module ActionsArtifacts
|
9
|
+
# List all artifacts for a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
#
|
13
|
+
# @return [Sawyer::Resource] the total count and an array of artifacts
|
14
|
+
# @see https://developer.github.com/v3/actions/artifacts#list-artifacts-for-a-repository
|
15
|
+
def repository_artifacts(repo, options = {})
|
16
|
+
paginate "#{Repository.path repo}/actions/artifacts", options do |data, last_response|
|
17
|
+
data.artifacts.concat last_response.data.artifacts
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# List all artifacts for a workflow run
|
22
|
+
#
|
23
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
24
|
+
# @param workflow_run_id [Integer] Id of a workflow run
|
25
|
+
#
|
26
|
+
# @return [Sawyer::Resource] the total count and an array of artifacts
|
27
|
+
# @see https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts
|
28
|
+
def workflow_run_artifacts(repo, workflow_run_id, options = {})
|
29
|
+
paginate "#{Repository.path repo}/actions/runs/#{workflow_run_id}/artifacts", options do |data, last_response|
|
30
|
+
data.artifacts.concat last_response.data.artifacts
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get an artifact
|
35
|
+
#
|
36
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
37
|
+
# @param id [Integer] Id of an artifact
|
38
|
+
#
|
39
|
+
# @return [Sawyer::Resource] Artifact information
|
40
|
+
# @see https://docs.github.com/en/rest/actions/artifacts#get-an-artifact
|
41
|
+
def artifact(repo, id, options = {})
|
42
|
+
get "#{Repository.path repo}/actions/artifacts/#{id}", options
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get a download URL for an artifact
|
46
|
+
#
|
47
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
48
|
+
# @param id [Integer] Id of an artifact
|
49
|
+
#
|
50
|
+
# @return [String] URL to the .zip archive of the artifact
|
51
|
+
# @see https://docs.github.com/en/rest/actions/artifacts#download-an-artifact
|
52
|
+
def artifact_download_url(repo, id, options = {})
|
53
|
+
url = "#{Repository.path repo}/actions/artifacts/#{id}/zip"
|
54
|
+
|
55
|
+
response = client_without_redirects.head(url, options)
|
56
|
+
response.headers['Location']
|
57
|
+
end
|
58
|
+
|
59
|
+
# Delete an artifact
|
60
|
+
#
|
61
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
62
|
+
# @param id [Integer] Id of an artifact
|
63
|
+
#
|
64
|
+
# @return [Boolean] Return true if the artifact was successfully deleted
|
65
|
+
# @see https://docs.github.com/en/rest/actions/artifacts#delete-an-artifact
|
66
|
+
def delete_artifact(repo, id, options = {})
|
67
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/artifacts/#{id}", options
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Actions Secrets API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/actions/secrets/
|
8
|
+
module ActionsSecrets
|
9
|
+
# Get public key for secrets encryption
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Hash] key_id and key
|
13
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
|
14
|
+
def get_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# List secrets
|
19
|
+
#
|
20
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
21
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
22
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
|
23
|
+
def list_secrets(repo)
|
24
|
+
paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
|
25
|
+
data.secrets.concat last_response.data.secrets
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get a secret
|
30
|
+
#
|
31
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
32
|
+
# @param name [String] Name of secret
|
33
|
+
# @return [Hash] name, created_at and updated_at
|
34
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
35
|
+
def get_secret(repo, name)
|
36
|
+
get "#{Repository.path repo}/actions/secrets/#{name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create or update secrets
|
40
|
+
#
|
41
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
42
|
+
# @param name [String] Name of secret
|
43
|
+
# @param options [Hash] encrypted_value and key_id
|
44
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
45
|
+
def create_or_update_secret(repo, name, options)
|
46
|
+
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
47
|
+
end
|
48
|
+
|
49
|
+
# Delete a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
54
|
+
def delete_secret(repo, name)
|
55
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Actions Workflows jobs API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs
|
8
|
+
module ActionsWorkflowJobs
|
9
|
+
# Get a job for a workflow run
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
# @param job_id [Integer, String] Id of the job
|
13
|
+
#
|
14
|
+
# @return [Sawyer::Resource] Job information
|
15
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run
|
16
|
+
def workflow_run_job(repo, job_id, options = {})
|
17
|
+
get "#{Repository.path repo}/actions/jobs/#{job_id}", options
|
18
|
+
end
|
19
|
+
|
20
|
+
# Download job logs for a workflow run
|
21
|
+
#
|
22
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
23
|
+
# @param job_id [Integer, String] Id of the job
|
24
|
+
#
|
25
|
+
# @return [String] URL to the archived log files of the job
|
26
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run
|
27
|
+
def workflow_run_job_logs(repo, job_id, options = {})
|
28
|
+
url = "#{Repository.path repo}/actions/jobs/#{job_id}/logs"
|
29
|
+
|
30
|
+
response = client_without_redirects.head(url, options)
|
31
|
+
response.headers['Location']
|
32
|
+
end
|
33
|
+
|
34
|
+
# List jobs for a workflow run attempt
|
35
|
+
#
|
36
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
37
|
+
# @param run_id [Integer, String] Id of the workflow run
|
38
|
+
# @param attempt_number [Integer, String] Attempt number of the workflow run
|
39
|
+
#
|
40
|
+
# @return [Sawyer::Resource] Jobs information
|
41
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run-attempt
|
42
|
+
def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})
|
43
|
+
paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options do |data, last_response|
|
44
|
+
data.jobs.concat last_response.data.jobs
|
45
|
+
end
|
46
|
+
end
|
47
|
+
alias list_workflow_run_attempt_jobs workflow_run_attempt_jobs
|
48
|
+
|
49
|
+
# List jobs for a workflow run
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
52
|
+
# @param run_id [Integer, String] Id of the workflow run
|
53
|
+
# @option options [String] :filter Optional filtering by a `completed_at` timestamp
|
54
|
+
#
|
55
|
+
# @return [Sawyer::Resource] Jobs information
|
56
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
|
57
|
+
def workflow_run_jobs(repo, run_id, options = {})
|
58
|
+
paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options do |data, last_response|
|
59
|
+
data.jobs.concat last_response.data.jobs
|
60
|
+
end
|
61
|
+
end
|
62
|
+
alias list_workflow_run_jobs workflow_run_jobs
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Actions Workflows runs API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/rest/actions/workflow-runs
|
8
|
+
module ActionsWorkflowRuns
|
9
|
+
# List all runs for a repository workflow
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
# @param workflow [Integer, String] Id or file name of the workflow
|
13
|
+
# @option options [String] :actor Optional filtering by a user
|
14
|
+
# @option options [String] :branch Optional filtering by a branch
|
15
|
+
# @option options [String] :event Optional filtering by the event type
|
16
|
+
# @option options [String] :status Optional filtering by a status or conclusion
|
17
|
+
#
|
18
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
19
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
|
20
|
+
def workflow_runs(repo, workflow, options = {})
|
21
|
+
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options do |data, last_response|
|
22
|
+
data.workflow_runs.concat last_response.data.workflow_runs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
alias list_workflow_runs workflow_runs
|
26
|
+
|
27
|
+
# List all workflow runs for a repository
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
30
|
+
# @option options [String] :actor Optional filtering by the login of a user
|
31
|
+
# @option options [String] :branch Optional filtering by a branch
|
32
|
+
# @option options [String] :event Optional filtering by the event type (e.g. push, pull_request, issue)
|
33
|
+
# @option options [String] :status Optional filtering by a status or conclusion (e.g. success, completed...)
|
34
|
+
#
|
35
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
36
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
|
37
|
+
def repository_workflow_runs(repo, options = {})
|
38
|
+
paginate "#{Repository.path repo}/actions/runs", options do |data, last_response|
|
39
|
+
data.workflow_runs.concat last_response.data.workflow_runs
|
40
|
+
end
|
41
|
+
end
|
42
|
+
alias list_repository_workflow_runs repository_workflow_runs
|
43
|
+
|
44
|
+
# Get a workflow run
|
45
|
+
#
|
46
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
47
|
+
# @param id [Integer] Id of a workflow run
|
48
|
+
#
|
49
|
+
# @return [Sawyer::Resource] Run information
|
50
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
51
|
+
def workflow_run(repo, id, options = {})
|
52
|
+
get "#{Repository.path repo}/actions/runs/#{id}", options
|
53
|
+
end
|
54
|
+
|
55
|
+
# Re-runs a workflow run
|
56
|
+
#
|
57
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
58
|
+
# @param id [Integer] Id of a workflow run
|
59
|
+
#
|
60
|
+
# @return [Boolean] Returns true if the re-run request was accepted
|
61
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
62
|
+
def rerun_workflow_run(repo, id, options = {})
|
63
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/rerun", options
|
64
|
+
end
|
65
|
+
|
66
|
+
# Cancels a workflow run
|
67
|
+
#
|
68
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
69
|
+
# @param id [Integer] Id of a workflow run
|
70
|
+
#
|
71
|
+
# @return [Boolean] Returns true if the cancellation was accepted
|
72
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
73
|
+
def cancel_workflow_run(repo, id, options = {})
|
74
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/cancel", options
|
75
|
+
end
|
76
|
+
|
77
|
+
# Deletes a workflow run
|
78
|
+
#
|
79
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
80
|
+
# @param id [Integer] Id of a workflow run
|
81
|
+
#
|
82
|
+
# @return [Boolean] Returns true if the run is deleted
|
83
|
+
# @see https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
|
84
|
+
def delete_workflow_run(repo, id, options = {})
|
85
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}", options
|
86
|
+
end
|
87
|
+
|
88
|
+
# Get a download url for archived log files of a workflow run
|
89
|
+
#
|
90
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
91
|
+
# @param id [Integer] Id of a workflow run
|
92
|
+
#
|
93
|
+
# @return [String] URL to the archived log files of the run
|
94
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
95
|
+
def workflow_run_logs(repo, id, options = {})
|
96
|
+
url = "#{Repository.path repo}/actions/runs/#{id}/logs"
|
97
|
+
|
98
|
+
response = client_without_redirects.head(url, options)
|
99
|
+
response.headers['Location']
|
100
|
+
end
|
101
|
+
|
102
|
+
# Delete all log files of a workflow run
|
103
|
+
#
|
104
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
105
|
+
# @param id [Integer] Id of a workflow run
|
106
|
+
#
|
107
|
+
# @return [Boolean] Returns true if the logs are deleted
|
108
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
109
|
+
def delete_workflow_run_logs(repo, id, options = {})
|
110
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
|
111
|
+
end
|
112
|
+
|
113
|
+
# Get workflow run usage
|
114
|
+
#
|
115
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
116
|
+
# @param id [Integer] Id of a workflow run
|
117
|
+
#
|
118
|
+
# @return [Sawyer::Resource] Run usage
|
119
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
120
|
+
def workflow_run_usage(repo, id, options = {})
|
121
|
+
get "#{Repository.path repo}/actions/runs/#{id}/timing", options
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Actions Workflows API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/actions/workflows
|
8
|
+
module ActionsWorkflows
|
9
|
+
# Get the workflows in a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
#
|
13
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
14
|
+
# @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
15
|
+
def workflows(repo, options = {})
|
16
|
+
paginate "#{Repository.path repo}/actions/workflows", options do |data, last_response|
|
17
|
+
data.workflows.concat last_response.data.workflows
|
18
|
+
end
|
19
|
+
end
|
20
|
+
alias list_workflows workflows
|
21
|
+
|
22
|
+
# Get single workflow in a repository
|
23
|
+
#
|
24
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
25
|
+
# @param id [Integer, String] Id or file name of the workflow
|
26
|
+
#
|
27
|
+
# @return [Sawyer::Resource] A single workflow
|
28
|
+
# @see https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
29
|
+
def workflow(repo, id, options = {})
|
30
|
+
get "#{Repository.path repo}/actions/workflows/#{id}", options
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create a workflow dispatch event
|
34
|
+
#
|
35
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
36
|
+
# @param id [Integer, String] Id or file name of the workflow
|
37
|
+
# @param ref [String] A SHA, branch name, or tag name
|
38
|
+
#
|
39
|
+
# @return [Boolean] True if event was dispatched, false otherwise
|
40
|
+
# @see https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
|
41
|
+
def workflow_dispatch(repo, id, ref, options = {})
|
42
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
|
43
|
+
end
|
44
|
+
|
45
|
+
# Enable a workflow
|
46
|
+
#
|
47
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
48
|
+
# @param id [Integer, String] Id or file name of the workflow
|
49
|
+
#
|
50
|
+
# @return [Boolean] True if workflow was enabled, false otherwise
|
51
|
+
# @see https://docs.github.com/en/rest/actions/workflows#enable-a-workflow
|
52
|
+
def workflow_enable(repo, id, options = {})
|
53
|
+
boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/enable", options
|
54
|
+
end
|
55
|
+
|
56
|
+
# Disable a workflow
|
57
|
+
#
|
58
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
59
|
+
# @param id [Integer, String] Id or file name of the workflow
|
60
|
+
#
|
61
|
+
# @return [Boolean] True if workflow was disabled, false otherwise
|
62
|
+
# @see https://docs.github.com/en/rest/actions/workflows#disable-a-workflow
|
63
|
+
def workflow_disable(repo, id, options = {})
|
64
|
+
boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/disable", options
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|