octokit 4.6.2 → 5.2.0
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 +218 -109
- data/Rakefile +5 -3
- 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_secrets.rb +57 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +61 -0
- data/lib/octokit/client/actions_workflow_runs.rb +121 -0
- data/lib/octokit/client/actions_workflows.rb +66 -0
- data/lib/octokit/client/apps.rb +222 -0
- data/lib/octokit/client/authorizations.rb +30 -89
- 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/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 +10 -10
- 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 +181 -61
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +49 -69
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +47 -46
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +33 -18
- data/lib/octokit/client/releases.rb +14 -13
- data/lib/octokit/client/repositories.rb +194 -53
- 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 +45 -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/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +106 -25
- data/lib/octokit/client.rb +60 -15
- data/lib/octokit/configurable.rb +42 -30
- data/lib/octokit/connection.rb +34 -20
- data/lib/octokit/default.rb +61 -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 +106 -25
- data/lib/octokit/gist.rb +3 -4
- data/lib/octokit/middleware/follow_redirects.rb +17 -13
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +6 -6
- 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 +52 -21
- data/lib/octokit/preview.rb +0 -35
data/Rakefile
CHANGED
@@ -1,11 +1,13 @@
|
|
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
13
|
begin
|
@@ -14,7 +16,7 @@ namespace :doc do
|
|
14
16
|
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
|
15
17
|
task.options = [
|
16
18
|
'--output-dir', 'doc/yard',
|
17
|
-
'--markup', 'markdown'
|
19
|
+
'--markup', 'markdown'
|
18
20
|
]
|
19
21
|
end
|
20
22
|
rescue LoadError
|
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,57 @@
|
|
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"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get a secret
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @param name [String] Name of secret
|
31
|
+
# @return [Hash] name, created_at and updated_at
|
32
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
33
|
+
def get_secret(repo, name)
|
34
|
+
get "#{Repository.path repo}/actions/secrets/#{name}"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Create or update secrets
|
38
|
+
#
|
39
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
40
|
+
# @param name [String] Name of secret
|
41
|
+
# @param options [Hash] encrypted_value and key_id
|
42
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
43
|
+
def create_or_update_secret(repo, name, options)
|
44
|
+
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
45
|
+
end
|
46
|
+
|
47
|
+
# Delete a secret
|
48
|
+
#
|
49
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
50
|
+
# @param name [String] Name of secret
|
51
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
52
|
+
def delete_secret(repo, name)
|
53
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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
|
44
|
+
end
|
45
|
+
alias list_workflow_run_attempt_jobs workflow_run_attempt_jobs
|
46
|
+
|
47
|
+
# List jobs for a workflow run
|
48
|
+
#
|
49
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
50
|
+
# @param run_id [Integer, String] Id of the workflow run
|
51
|
+
# @option options [String] :filter Optional filtering by a `completed_at` timestamp
|
52
|
+
#
|
53
|
+
# @return [Sawyer::Resource] Jobs information
|
54
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
|
55
|
+
def workflow_run_jobs(repo, run_id, options = {})
|
56
|
+
paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options
|
57
|
+
end
|
58
|
+
alias list_workflow_run_jobs workflow_run_jobs
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,121 @@
|
|
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
|
22
|
+
end
|
23
|
+
alias list_workflow_runs workflow_runs
|
24
|
+
|
25
|
+
# List all workflow runs for a repository
|
26
|
+
#
|
27
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
28
|
+
# @option options [String] :actor Optional filtering by the login of a user
|
29
|
+
# @option options [String] :branch Optional filtering by a branch
|
30
|
+
# @option options [String] :event Optional filtering by the event type (e.g. push, pull_request, issue)
|
31
|
+
# @option options [String] :status Optional filtering by a status or conclusion (e.g. success, completed...)
|
32
|
+
#
|
33
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
34
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
|
35
|
+
def repository_workflow_runs(repo, options = {})
|
36
|
+
paginate "#{Repository.path repo}/actions/runs", options
|
37
|
+
end
|
38
|
+
alias list_repository_workflow_runs repository_workflow_runs
|
39
|
+
|
40
|
+
# Get a workflow run
|
41
|
+
#
|
42
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
43
|
+
# @param id [Integer] Id of a workflow run
|
44
|
+
#
|
45
|
+
# @return [Sawyer::Resource] Run information
|
46
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
47
|
+
def workflow_run(repo, id, options = {})
|
48
|
+
get "#{Repository.path repo}/actions/runs/#{id}", options
|
49
|
+
end
|
50
|
+
|
51
|
+
# Re-runs a workflow run
|
52
|
+
#
|
53
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
54
|
+
# @param id [Integer] Id of a workflow run
|
55
|
+
#
|
56
|
+
# @return [Boolean] Returns true if the re-run request was accepted
|
57
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
58
|
+
def rerun_workflow_run(repo, id, options = {})
|
59
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/rerun", options
|
60
|
+
end
|
61
|
+
|
62
|
+
# Cancels a workflow run
|
63
|
+
#
|
64
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
65
|
+
# @param id [Integer] Id of a workflow run
|
66
|
+
#
|
67
|
+
# @return [Boolean] Returns true if the cancellation was accepted
|
68
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
69
|
+
def cancel_workflow_run(repo, id, options = {})
|
70
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/cancel", options
|
71
|
+
end
|
72
|
+
|
73
|
+
# Deletes a workflow run
|
74
|
+
#
|
75
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
76
|
+
# @param id [Integer] Id of a workflow run
|
77
|
+
#
|
78
|
+
# @return [Boolean] Returns true if the run is deleted
|
79
|
+
# @see https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
|
80
|
+
def delete_workflow_run(repo, id, options = {})
|
81
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}", options
|
82
|
+
end
|
83
|
+
|
84
|
+
# Get a download url for archived log files of a workflow run
|
85
|
+
#
|
86
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
87
|
+
# @param id [Integer] Id of a workflow run
|
88
|
+
#
|
89
|
+
# @return [String] URL to the archived log files of the run
|
90
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
91
|
+
def workflow_run_logs(repo, id, options = {})
|
92
|
+
url = "#{Repository.path repo}/actions/runs/#{id}/logs"
|
93
|
+
|
94
|
+
response = client_without_redirects.head(url, options)
|
95
|
+
response.headers['Location']
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete all log files of a workflow run
|
99
|
+
#
|
100
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
101
|
+
# @param id [Integer] Id of a workflow run
|
102
|
+
#
|
103
|
+
# @return [Boolean] Returns true if the logs are deleted
|
104
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
105
|
+
def delete_workflow_run_logs(repo, id, options = {})
|
106
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
|
107
|
+
end
|
108
|
+
|
109
|
+
# Get workflow run usage
|
110
|
+
#
|
111
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
112
|
+
# @param id [Integer] Id of a workflow run
|
113
|
+
#
|
114
|
+
# @return [Sawyer::Resource] Run usage
|
115
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
116
|
+
def workflow_run_usage(repo, id, options = {})
|
117
|
+
get "#{Repository.path repo}/actions/runs/#{id}/timing", options
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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
|
17
|
+
end
|
18
|
+
alias list_workflows workflows
|
19
|
+
|
20
|
+
# Get single workflow in a repository
|
21
|
+
#
|
22
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
23
|
+
# @param id [Integer, String] Id or file name of the workflow
|
24
|
+
#
|
25
|
+
# @return [Sawyer::Resource] A single workflow
|
26
|
+
# @see https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
27
|
+
def workflow(repo, id, options = {})
|
28
|
+
get "#{Repository.path repo}/actions/workflows/#{id}", options
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create a workflow dispatch event
|
32
|
+
#
|
33
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
34
|
+
# @param id [Integer, String] Id or file name of the workflow
|
35
|
+
# @param ref [String] A SHA, branch name, or tag name
|
36
|
+
#
|
37
|
+
# @return [Boolean] True if event was dispatched, false otherwise
|
38
|
+
# @see https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
|
39
|
+
def workflow_dispatch(repo, id, ref, options = {})
|
40
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
|
41
|
+
end
|
42
|
+
|
43
|
+
# Enable a workflow
|
44
|
+
#
|
45
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
46
|
+
# @param id [Integer, String] Id or file name of the workflow
|
47
|
+
#
|
48
|
+
# @return [Boolean] True if workflow was enabled, false otherwise
|
49
|
+
# @see https://docs.github.com/en/rest/actions/workflows#enable-a-workflow
|
50
|
+
def workflow_enable(repo, id, options = {})
|
51
|
+
boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/enable", options
|
52
|
+
end
|
53
|
+
|
54
|
+
# Disable a workflow
|
55
|
+
#
|
56
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
57
|
+
# @param id [Integer, String] Id or file name of the workflow
|
58
|
+
#
|
59
|
+
# @return [Boolean] True if workflow was disabled, false otherwise
|
60
|
+
# @see https://docs.github.com/en/rest/actions/workflows#disable-a-workflow
|
61
|
+
def workflow_disable(repo, id, options = {})
|
62
|
+
boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/disable", options
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Apps API
|
6
|
+
module Apps
|
7
|
+
# Get the authenticated App
|
8
|
+
#
|
9
|
+
# @param options [Hash] A customizable set of options
|
10
|
+
#
|
11
|
+
# @see https://developer.github.com/v3/apps/#get-the-authenticated-app
|
12
|
+
#
|
13
|
+
# @return [Sawyer::Resource] App information
|
14
|
+
def app(options = {})
|
15
|
+
get 'app', options
|
16
|
+
end
|
17
|
+
|
18
|
+
# Find all installations that belong to an App
|
19
|
+
#
|
20
|
+
# @param options [Hash] A customizable set of options
|
21
|
+
#
|
22
|
+
# @see https://developer.github.com/v3/apps/#list-installations
|
23
|
+
#
|
24
|
+
# @return [Array<Sawyer::Resource>] the total_count and an array of installations
|
25
|
+
def find_app_installations(options = {})
|
26
|
+
paginate 'app/installations', options
|
27
|
+
end
|
28
|
+
alias find_installations find_app_installations
|
29
|
+
|
30
|
+
def find_integration_installations(options = {})
|
31
|
+
octokit_warn(
|
32
|
+
'Deprecated: Octokit::Client::Apps#find_integration_installations ' \
|
33
|
+
'method is deprecated. Please update your call to use ' \
|
34
|
+
'Octokit::Client::Apps#find_app_installations before the next major ' \
|
35
|
+
'Octokit version update.'
|
36
|
+
)
|
37
|
+
find_app_installations(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Find all installations that are accessible to the authenticated user
|
41
|
+
#
|
42
|
+
# @param options [Hash] A customizable set of options
|
43
|
+
#
|
44
|
+
# @see https://developer.github.com/v3/apps/installations/#list-installations-for-a-user
|
45
|
+
#
|
46
|
+
# @return [Sawyer::Resource] the total_count and an array of installations
|
47
|
+
def find_user_installations(options = {})
|
48
|
+
paginate('user/installations', options) do |data, last_response|
|
49
|
+
data.installations.concat last_response.data.installations
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get a single installation
|
54
|
+
#
|
55
|
+
# @param id [Integer] Installation id
|
56
|
+
#
|
57
|
+
# @see https://developer.github.com/v3/apps/#get-an-installation
|
58
|
+
#
|
59
|
+
# @return [Sawyer::Resource] Installation information
|
60
|
+
def installation(id, options = {})
|
61
|
+
get "app/installations/#{id}", options
|
62
|
+
end
|
63
|
+
|
64
|
+
# Create a new installation token
|
65
|
+
#
|
66
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
67
|
+
# @param options [Hash] A customizable set of options
|
68
|
+
#
|
69
|
+
# @see https://developer.github.com/v3/apps/#create-a-new-installation-token
|
70
|
+
#
|
71
|
+
# @return [<Sawyer::Resource>] An installation token
|
72
|
+
def create_app_installation_access_token(installation, options = {})
|
73
|
+
post "app/installations/#{installation}/access_tokens", options
|
74
|
+
end
|
75
|
+
alias create_installation_access_token create_app_installation_access_token
|
76
|
+
|
77
|
+
def create_integration_installation_access_token(installation, options = {})
|
78
|
+
octokit_warn(
|
79
|
+
'Deprecated: Octokit::Client::Apps#create_integration_installation_access_token ' \
|
80
|
+
'method is deprecated. Please update your call to use ' \
|
81
|
+
'Octokit::Client::Apps#create_app_installation_access_token before the next major ' \
|
82
|
+
'Octokit version update.'
|
83
|
+
)
|
84
|
+
create_app_installation_access_token(installation, options)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Enables an app to find the organization's installation information.
|
88
|
+
#
|
89
|
+
# @param organization [String] Organization GitHub login
|
90
|
+
# @param options [Hash] A customizable set of options
|
91
|
+
#
|
92
|
+
# @see https://developer.github.com/v3/apps/#get-an-organization-installation
|
93
|
+
#
|
94
|
+
# @return [Sawyer::Resource] Installation information
|
95
|
+
def find_organization_installation(organization, options = {})
|
96
|
+
get "#{Organization.path(organization)}/installation", options
|
97
|
+
end
|
98
|
+
|
99
|
+
# Enables an app to find the repository's installation information.
|
100
|
+
#
|
101
|
+
# @param repo [String] A GitHub repository
|
102
|
+
# @param options [Hash] A customizable set of options
|
103
|
+
#
|
104
|
+
# @see https://developer.github.com/v3/apps/#get-a-repository-installation
|
105
|
+
#
|
106
|
+
# @return [Sawyer::Resource] Installation information
|
107
|
+
def find_repository_installation(repo, options = {})
|
108
|
+
get "#{Repository.path(repo)}/installation", options
|
109
|
+
end
|
110
|
+
|
111
|
+
# Enables an app to find the user's installation information.
|
112
|
+
#
|
113
|
+
# @param user [String] GitHub user login
|
114
|
+
# @param options [Hash] A customizable set of options
|
115
|
+
#
|
116
|
+
# @see https://developer.github.com/v3/apps/#get-a-user-installation
|
117
|
+
#
|
118
|
+
# @return [Sawyer::Resource] Installation information
|
119
|
+
def find_user_installation(user, options = {})
|
120
|
+
get "#{User.path(user)}/installation", options
|
121
|
+
end
|
122
|
+
|
123
|
+
# List repositories that are accessible to the authenticated installation
|
124
|
+
#
|
125
|
+
# @param options [Hash] A customizable set of options
|
126
|
+
#
|
127
|
+
# @see https://developer.github.com/v3/apps/installations/#list-repositories
|
128
|
+
#
|
129
|
+
# @return [Sawyer::Resource] the total_count and an array of repositories
|
130
|
+
def list_app_installation_repositories(options = {})
|
131
|
+
paginate('installation/repositories', options) do |data, last_response|
|
132
|
+
data.repositories.concat last_response.data.repositories
|
133
|
+
end
|
134
|
+
end
|
135
|
+
alias list_installation_repos list_app_installation_repositories
|
136
|
+
|
137
|
+
def list_integration_installation_repositories(options = {})
|
138
|
+
octokit_warn(
|
139
|
+
'Deprecated: Octokit::Client::Apps#list_integration_installation_repositories ' \
|
140
|
+
'method is deprecated. Please update your call to use ' \
|
141
|
+
'Octokit::Client::Apps#list_app_installation_repositories before the next major ' \
|
142
|
+
'Octokit version update.'
|
143
|
+
)
|
144
|
+
list_app_installation_repositories(options)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Add a single repository to an installation
|
148
|
+
#
|
149
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
150
|
+
# @param repo [Integer] The id of the GitHub repository
|
151
|
+
# @param options [Hash] A customizable set of options
|
152
|
+
#
|
153
|
+
# @see https://developer.github.com/v3/apps/installations/#add-repository-to-installation
|
154
|
+
#
|
155
|
+
# @return [Boolean] Success
|
156
|
+
def add_repository_to_app_installation(installation, repo, options = {})
|
157
|
+
boolean_from_response :put, "user/installations/#{installation}/repositories/#{repo}", options
|
158
|
+
end
|
159
|
+
alias add_repo_to_installation add_repository_to_app_installation
|
160
|
+
|
161
|
+
def add_repository_to_integration_installation(installation, repo, options = {})
|
162
|
+
octokit_warn(
|
163
|
+
'Deprecated: Octokit::Client::Apps#add_repository_to_integration_installation ' \
|
164
|
+
'method is deprecated. Please update your call to use ' \
|
165
|
+
'Octokit::Client::Apps#add_repository_to_app_installation before the next major ' \
|
166
|
+
'Octokit version update.'
|
167
|
+
)
|
168
|
+
add_repository_to_app_installation(installation, repo, options)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Remove a single repository to an installation
|
172
|
+
#
|
173
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
174
|
+
# @param repo [Integer] The id of the GitHub repository
|
175
|
+
# @param options [Hash] A customizable set of options
|
176
|
+
#
|
177
|
+
# @see https://developer.github.com/v3/apps/installations/#remove-repository-from-installation
|
178
|
+
#
|
179
|
+
# @return [Boolean] Success
|
180
|
+
def remove_repository_from_app_installation(installation, repo, options = {})
|
181
|
+
boolean_from_response :delete, "user/installations/#{installation}/repositories/#{repo}", options
|
182
|
+
end
|
183
|
+
alias remove_repo_from_installation remove_repository_from_app_installation
|
184
|
+
|
185
|
+
def remove_repository_from_integration_installation(installation, repo, options = {})
|
186
|
+
octokit_warn(
|
187
|
+
'Deprecated: Octokit::Client::Apps#remove_repository_from_integration_installation ' \
|
188
|
+
'method is deprecated. Please update your call to use ' \
|
189
|
+
'Octokit::Client::Apps#remove_repository_from_app_installation before the next major ' \
|
190
|
+
'Octokit version update.'
|
191
|
+
)
|
192
|
+
remove_repository_from_app_installation(installation, repo, options)
|
193
|
+
end
|
194
|
+
|
195
|
+
# List repositories accessible to the user for an installation
|
196
|
+
#
|
197
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
198
|
+
# @param options [Hash] A customizable set of options
|
199
|
+
#
|
200
|
+
# @see https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
|
201
|
+
#
|
202
|
+
# @return [Sawyer::Resource] the total_count and an array of repositories
|
203
|
+
def find_installation_repositories_for_user(installation, options = {})
|
204
|
+
paginate("user/installations/#{installation}/repositories", options) do |data, last_response|
|
205
|
+
data.repositories.concat last_response.data.repositories
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Delete an installation and uninstall a GitHub App
|
210
|
+
#
|
211
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
212
|
+
# @param options [Hash] A customizable set of options
|
213
|
+
#
|
214
|
+
# @see https://developer.github.com/v3/apps/#delete-an-installation
|
215
|
+
#
|
216
|
+
# @return [Boolean] Success
|
217
|
+
def delete_installation(installation, options = {})
|
218
|
+
boolean_from_response :delete, "app/installations/#{installation}", options
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|