octokit 4.2.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -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 +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -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 +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- 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 +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- 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 +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- 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 +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- 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 +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
data/Rakefile
CHANGED
@@ -1,22 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler'
|
2
4
|
Bundler::GemHelper.install_tasks
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
task test: :spec
|
7
|
+
task default: :spec
|
6
8
|
|
7
|
-
|
8
|
-
task :
|
9
|
+
desc 'Run RSpec'
|
10
|
+
task :spec do
|
11
|
+
if Process.respond_to?(:fork)
|
12
|
+
sh('rspec-queue')
|
13
|
+
else
|
14
|
+
sh('rspec')
|
15
|
+
end
|
16
|
+
end
|
9
17
|
|
10
18
|
namespace :doc do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
]
|
19
|
-
end
|
20
|
-
rescue LoadError
|
19
|
+
require 'yard'
|
20
|
+
YARD::Rake::YardocTask.new do |task|
|
21
|
+
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
|
22
|
+
task.options = [
|
23
|
+
'--output-dir', 'doc/yard',
|
24
|
+
'--markup', 'markdown'
|
25
|
+
]
|
21
26
|
end
|
27
|
+
rescue LoadError
|
22
28
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sawyer'
|
4
|
+
|
5
|
+
patch = Module.new do
|
6
|
+
def href(options = nil)
|
7
|
+
# Temporary workaround for: https://github.com/octokit/octokit.rb/issues/727
|
8
|
+
name.to_s == 'ssh' ? @href : super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Sawyer::Relation.send(:prepend, patch)
|
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
|
@@ -7,8 +8,7 @@ module Octokit
|
|
7
8
|
|
8
9
|
def initialize(args)
|
9
10
|
@options = args.last.is_a?(::Hash) ? args.pop : {}
|
10
|
-
super
|
11
|
+
super
|
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,161 @@
|
|
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_actions_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
|
23
|
+
def get_org_actions_public_key(org)
|
24
|
+
get "#{Organization.path org}/actions/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
27
|
+
# List secrets
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
31
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
|
32
|
+
def list_actions_secrets(repo)
|
33
|
+
paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
|
34
|
+
data.secrets.concat last_response.data.secrets
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-organization-secrets
|
43
|
+
def list_org_actions_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/actions/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @return [Hash] name, created_at and updated_at
|
54
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
55
|
+
def get_actions_secret(repo, name)
|
56
|
+
get "#{Repository.path repo}/actions/secrets/#{name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at and updated_at
|
64
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
65
|
+
def get_org_actions_secret(org, name)
|
66
|
+
get "#{Organization.path org}/actions/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create or update secrets
|
70
|
+
#
|
71
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
72
|
+
# @param name [String] Name of secret
|
73
|
+
# @param options [Hash] encrypted_value and key_id
|
74
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
75
|
+
def create_or_update_actions_secret(repo, name, options)
|
76
|
+
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret
|
85
|
+
def create_or_update_org_actions_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/actions/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
89
|
+
# Delete a secret
|
90
|
+
#
|
91
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
92
|
+
# @param name [String] Name of secret
|
93
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
94
|
+
def delete_actions_secret(repo, name)
|
95
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret
|
103
|
+
def delete_org_actions_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/actions/secrets/#{name}"
|
105
|
+
end
|
106
|
+
|
107
|
+
# Get environment public key for secrets encryption
|
108
|
+
#
|
109
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
110
|
+
# @param environment [String] Name of environment
|
111
|
+
# @return [Hash] key_id and key
|
112
|
+
# @see https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key
|
113
|
+
def get_actions_environment_public_key(repo, environment)
|
114
|
+
get "#{Repository.path repo}/environments/#{environment}/secrets/public-key"
|
115
|
+
end
|
116
|
+
|
117
|
+
# List environment secrets
|
118
|
+
#
|
119
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
120
|
+
# @param environment [String] Name of environment
|
121
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
122
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-environment-secrets
|
123
|
+
def list_actions_environment_secrets(repo, environment)
|
124
|
+
paginate "#{Repository.path repo}/environments/#{environment}/secrets" do |data, last_response|
|
125
|
+
data.secrets.concat last_response.data.secrets
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Get an environment secret
|
130
|
+
#
|
131
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
132
|
+
# @param environment [String] Name of environment
|
133
|
+
# @param name [String] Name of secret
|
134
|
+
# @return [Hash] name, created_at and updated_at
|
135
|
+
# @see https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret
|
136
|
+
def get_actions_environment_secret(repo, environment, name)
|
137
|
+
get "#{Repository.path repo}/environments/#{environment}/secrets/#{name}"
|
138
|
+
end
|
139
|
+
|
140
|
+
# Create or update an environment secret
|
141
|
+
#
|
142
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
143
|
+
# @param environment [String] Name of environment
|
144
|
+
# @param name [String] Name of secret
|
145
|
+
# @param options [Hash] encrypted_value and key_id
|
146
|
+
# @see https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret
|
147
|
+
def create_or_update_actions_environment_secret(repo, environment, name, options)
|
148
|
+
put "#{Repository.path repo}/environments/#{environment}/secrets/#{name}", options
|
149
|
+
end
|
150
|
+
|
151
|
+
# Delete environment secret
|
152
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
153
|
+
# @param environment [String] Name of environment
|
154
|
+
# @param name [String] Name of secret
|
155
|
+
# @see https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret
|
156
|
+
def delete_actions_environment_secret(repo, environment, name)
|
157
|
+
boolean_from_response :delete, "#{Repository.path repo}/environments/#{environment}/secrets/#{name}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
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
|