octokit 7.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 +4 -4
- data/README.md +6 -22
- data/lib/octokit/arguments.rb +1 -1
- data/lib/octokit/client/actions_secrets.rb +49 -0
- data/lib/octokit/client/apps.rb +12 -0
- data/lib/octokit/client/code_scanning.rb +139 -2
- data/lib/octokit/client/codespaces_secrets.rb +49 -0
- data/lib/octokit/client/contents.rb +1 -3
- data/lib/octokit/client/dependabot_secrets.rb +49 -0
- data/lib/octokit/client/deployments.rb +2 -2
- data/lib/octokit/client/environments.rb +4 -1
- data/lib/octokit/client/oauth_applications.rb +1 -1
- data/lib/octokit/client/pull_requests.rb +18 -9
- data/lib/octokit/client/reactions.rb +49 -0
- data/lib/octokit/client/repositories.rb +43 -0
- data/lib/octokit/client/users.rb +27 -0
- data/lib/octokit/client.rb +2 -2
- data/lib/octokit/configurable.rb +17 -1
- data/lib/octokit/connection.rb +2 -0
- data/lib/octokit/default.rb +18 -0
- data/lib/octokit/enterprise_management_console_client/management_console.rb +19 -1
- data/lib/octokit/error.rb +6 -0
- 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 +1 -1
- data/lib/octokit/repo_arguments.rb +1 -1
- data/lib/octokit/repository.rb +7 -1
- data/lib/octokit/version.rb +1 -1
- data/lib/octokit.rb +16 -1
- metadata +8 -7
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b64084ad94f7ab597007ce5baa5e9daa39e85c0270c0993cde6bf416a2834a2c
|
4
|
+
data.tar.gz: 429a34488349b5692bc28e6051571e3e4bddfd7f697be93bd0e24c7329d1bd18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52b64720e7ffa14ab04bf59283194dd8a0b83ba73bf9acc3c0cfbb4ef36ba6e87257f7650969d597135c8c75eb3bc1bf7a3b7a20f2746c5670e92f7cea95a9f
|
7
|
+
data.tar.gz: b0598cc84a8d4571d9e3fc64d1ed63dcef618fba37e2d9e33346ef42a766e366bc2e38fc02b7c9561b0fc7fe28a7ed8984599390deb305f86af8e98b21033b29
|
data/README.md
CHANGED
@@ -81,7 +81,7 @@ Install via Rubygems
|
|
81
81
|
|
82
82
|
... or add to your Gemfile
|
83
83
|
|
84
|
-
gem "octokit"
|
84
|
+
gem "octokit"
|
85
85
|
|
86
86
|
Access the library in Ruby:
|
87
87
|
|
@@ -213,15 +213,7 @@ user.login
|
|
213
213
|
# => "defunkt"
|
214
214
|
```
|
215
215
|
|
216
|
-
You can [create access tokens through your GitHub Account Settings](https://help.github.com/articles/creating-an-access-token-for-command-line-use)
|
217
|
-
or with a basic authenticated Octokit client:
|
218
|
-
|
219
|
-
```ruby
|
220
|
-
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
221
|
-
|
222
|
-
client.create_authorization(:scopes => ["user"], :note => "Name of token")
|
223
|
-
# => <your new oauth token>
|
224
|
-
```
|
216
|
+
You can [create access tokens through your GitHub Account Settings](https://help.github.com/articles/creating-an-access-token-for-command-line-use).
|
225
217
|
|
226
218
|
### Two-Factor Authentication
|
227
219
|
|
@@ -237,18 +229,6 @@ client = Octokit::Client.new \
|
|
237
229
|
user = client.user("defunkt", :headers => { "X-GitHub-OTP" => "<your 2FA token>" })
|
238
230
|
```
|
239
231
|
|
240
|
-
As you can imagine, this gets annoying quickly since two-factor auth tokens are very short lived. So it is recommended to create an oauth token for the user to communicate with the API:
|
241
|
-
|
242
|
-
```ruby
|
243
|
-
client = Octokit::Client.new \
|
244
|
-
:login => 'defunkt',
|
245
|
-
:password => 'c0d3b4ssssss!'
|
246
|
-
|
247
|
-
client.create_authorization(:scopes => ["user"], :note => "Name of token",
|
248
|
-
:headers => { "X-GitHub-OTP" => "<your 2FA token>" })
|
249
|
-
# => <your new oauth token>
|
250
|
-
```
|
251
|
-
|
252
232
|
### Using a .netrc file
|
253
233
|
|
254
234
|
Octokit supports reading credentials from a netrc file (defaulting to
|
@@ -729,6 +709,9 @@ Octokit:
|
|
729
709
|
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password. |
|
730
710
|
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname. |
|
731
711
|
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint. |
|
712
|
+
| `OCTOKIT_TEST_GITHUB_MANAGE_GHES_ENDPOINT` | GitHub Enterprise Server GHES Manage Endpoint. |
|
713
|
+
| `OCTOKIT_TEST_GITHUB_MANAGE_GHES_USERNAME` | GitHub Enterprise Server GHES Manage Username. |
|
714
|
+
| `OCTOKIT_TEST_GITHUB_MANAGE_GHES_PASSWORD` | GitHub Enterprise Server GHES Manage Password. |
|
732
715
|
| `OCTOKIT_TEST_GITHUB_INTEGRATION` | [GitHub Integration](https://developer.github.com/early-access/integrations/) owned by your test organization. |
|
733
716
|
| `OCTOKIT_TEST_GITHUB_INTEGRATION_INSTALLATION` | Installation of the GitHub Integration specified above. |
|
734
717
|
| `OCTOKIT_TEST_INTEGRATION_PEM_KEY` | File path to the private key generated from your integration. |
|
@@ -758,6 +741,7 @@ implementations:
|
|
758
741
|
* Ruby 3.0
|
759
742
|
* Ruby 3.1
|
760
743
|
* Ruby 3.2
|
744
|
+
* Ruby 3.3
|
761
745
|
|
762
746
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
763
747
|
|
data/lib/octokit/arguments.rb
CHANGED
@@ -15,6 +15,15 @@ module Octokit
|
|
15
15
|
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
16
|
end
|
17
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
|
+
|
18
27
|
# List secrets
|
19
28
|
#
|
20
29
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -26,6 +35,17 @@ module Octokit
|
|
26
35
|
end
|
27
36
|
end
|
28
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
|
+
|
29
49
|
# Get a secret
|
30
50
|
#
|
31
51
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -36,6 +56,16 @@ module Octokit
|
|
36
56
|
get "#{Repository.path repo}/actions/secrets/#{name}"
|
37
57
|
end
|
38
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
|
+
|
39
69
|
# Create or update secrets
|
40
70
|
#
|
41
71
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -46,6 +76,16 @@ module Octokit
|
|
46
76
|
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
47
77
|
end
|
48
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
|
+
|
49
89
|
# Delete a secret
|
50
90
|
#
|
51
91
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -55,6 +95,15 @@ module Octokit
|
|
55
95
|
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
56
96
|
end
|
57
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
|
+
|
58
107
|
# Get environment public key for secrets encryption
|
59
108
|
#
|
60
109
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
data/lib/octokit/client/apps.rb
CHANGED
@@ -231,6 +231,18 @@ module Octokit
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
+
# Returns a delivery for the webhook configured for a GitHub App.
|
235
|
+
#
|
236
|
+
# @param delivery_id [String] The id of a GitHub App Hook Delivery
|
237
|
+
# @param options [Hash] A customizable set of options
|
238
|
+
#
|
239
|
+
# @see https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook
|
240
|
+
#
|
241
|
+
# @return [<Sawyer::Resource>] The webhook delivery
|
242
|
+
def app_hook_delivery(delivery_id, options = {})
|
243
|
+
get "/app/hook/deliveries/#{delivery_id}", options
|
244
|
+
end
|
245
|
+
|
234
246
|
# Redeliver a delivery for the webhook configured for a GitHub App.
|
235
247
|
#
|
236
248
|
# @param delivery_id [Integer] The id of a GitHub App Hook Delivery
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'base64'
|
4
3
|
require 'tempfile'
|
5
4
|
require 'zlib'
|
6
5
|
|
@@ -10,6 +9,144 @@ module Octokit
|
|
10
9
|
#
|
11
10
|
# @see https://docs.github.com/rest/code-scanning
|
12
11
|
module CodeScanning
|
12
|
+
# Updates a code scanning default setup configuration
|
13
|
+
#
|
14
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
15
|
+
# @param state [String] The desired state of code scanning default setup
|
16
|
+
# @param query_suite [String] CodeQL query suite to be used
|
17
|
+
# @param languages [Array] List of CodeQL languages to be analyzed
|
18
|
+
#
|
19
|
+
# @return [Sawyer::Resource] Action Run information
|
20
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#update-a-code-scanning-default-setup-configuration
|
21
|
+
def update_code_scanning_default_config(repo, state, query_suite = nil, languages = nil, options = {})
|
22
|
+
options[:state] = state
|
23
|
+
options[:query_suite] = query_suite if query_suite
|
24
|
+
options[:languages] = languages if languages
|
25
|
+
|
26
|
+
patch "#{Repository.path repo}/code-scanning/default-setup", options
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get Code Scanning Default Configuration
|
30
|
+
#
|
31
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
32
|
+
#
|
33
|
+
# @return [Sawyer::Resource] CodeQl Default Setup Configuration Information
|
34
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-default-setup-configuration
|
35
|
+
def get_code_scanning_default_config(repo, options = {})
|
36
|
+
get "#{Repository.path repo}/code-scanning/default-setup", options
|
37
|
+
end
|
38
|
+
|
39
|
+
# Gets a CodeQL database for a language in a repository
|
40
|
+
#
|
41
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
42
|
+
# @param language [String]
|
43
|
+
#
|
44
|
+
# @return [Sawyer::Resource] CodeQl Default Setup Configuration Information
|
45
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository
|
46
|
+
def get_codeql_database_for_repo(repo, language, options = {})
|
47
|
+
get "#{Repository.path repo}/code-scanning/codeql/databases/#{language}", options
|
48
|
+
end
|
49
|
+
|
50
|
+
# Lists the CodeQL databases that are available in a repository
|
51
|
+
#
|
52
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
53
|
+
#
|
54
|
+
# @return [Array] List of CodeQL Databases
|
55
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository
|
56
|
+
def list_codeql_database_for_repo(repo, options = {})
|
57
|
+
get "#{Repository.path repo}/code-scanning/codeql/databases", options
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete a specified code scanning analysis from a repository
|
61
|
+
#
|
62
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
63
|
+
# @param analysis_id [Integer] ID of the code scanning analysis
|
64
|
+
#
|
65
|
+
# @return [Sawyer::Resource] Next Code Scanning Analysis Information
|
66
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#delete-a-code-scanning-analysis-from-a-repository
|
67
|
+
def delete_code_scanning_analysis(repo, analysis_id, options = {})
|
68
|
+
delete "#{Repository.path repo}/code-scanning/analyses/#{analysis_id}", options
|
69
|
+
end
|
70
|
+
|
71
|
+
# Get a code scanning analysis for a repository
|
72
|
+
#
|
73
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
74
|
+
# @param analysis_id [Integer] ID of the code scanning analysis
|
75
|
+
#
|
76
|
+
# @return [Sawyer::Resource] Code Scanning Analysis
|
77
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository
|
78
|
+
def get_code_scanning_analysis(repo, analysis_id, options = {})
|
79
|
+
get "#{Repository.path repo}/code-scanning/analyses/#{analysis_id}", options
|
80
|
+
end
|
81
|
+
|
82
|
+
# List code scanning analyses for a repository
|
83
|
+
#
|
84
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
85
|
+
#
|
86
|
+
# @return [Array] List of Code Scanning Analyses
|
87
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-analyses-for-a-repository
|
88
|
+
def list_code_scanning_analysis(repo, options = {})
|
89
|
+
paginate "#{Repository.path repo}/code-scanning/analyses", options
|
90
|
+
end
|
91
|
+
|
92
|
+
# List instances of a code scanning alert
|
93
|
+
#
|
94
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
95
|
+
# @param alert_number [Integer] The number that identifies an alert
|
96
|
+
#
|
97
|
+
# @return [Array] List of Code Scanning Alerts
|
98
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-instances-of-a-code-scanning-alert
|
99
|
+
def list_instances_of_code_scanning_alert(repo, alert_number, options = {})
|
100
|
+
paginate "#{Repository.path repo}/code-scanning/alerts/#{alert_number}/instances", options
|
101
|
+
end
|
102
|
+
|
103
|
+
# Update a code scanning alert
|
104
|
+
#
|
105
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
106
|
+
# @param alert_number [Integer] The number that identifies an alert
|
107
|
+
# @param state [String] The reason for dismissing or closing the alert. Required when the state is dismissed
|
108
|
+
#
|
109
|
+
# @return [Sawyer::Resource] Code Scanning Alert information
|
110
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#update-a-code-scanning-alert
|
111
|
+
def update_code_scanning_alert(repo, alert_number, state, reason, comment = nil, options = {})
|
112
|
+
options[:state] = state
|
113
|
+
options[:dismissed_reason] = reason
|
114
|
+
options[:dismissed_comment] = comment if comment
|
115
|
+
|
116
|
+
patch "#{Repository.path repo}/code-scanning/alerts/#{alert_number}", options
|
117
|
+
end
|
118
|
+
|
119
|
+
# Gets a single code scanning alert
|
120
|
+
#
|
121
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
122
|
+
# @param alert_number [Integer] The number that identifies an alert
|
123
|
+
#
|
124
|
+
# @return [Sawyer::Resource] Code Scanning Alert
|
125
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-alert
|
126
|
+
def get_code_scanning_alert(repo, alert_number, options = {})
|
127
|
+
get "#{Repository.path repo}/code-scanning/alerts/#{alert_number}", options
|
128
|
+
end
|
129
|
+
|
130
|
+
# List code scanning alerts for a repository
|
131
|
+
#
|
132
|
+
# @param org [String] A GitHub organization
|
133
|
+
#
|
134
|
+
# @return [Array] Code Scanning Alert information
|
135
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-a-repository
|
136
|
+
def list_code_scanning_alerts_for_repo(repo, options = {})
|
137
|
+
paginate "#{Repository.path repo}/code-scanning/alerts", options
|
138
|
+
end
|
139
|
+
|
140
|
+
# List code scanning alerts for an organization
|
141
|
+
#
|
142
|
+
# @param org [String] A GitHub organization
|
143
|
+
#
|
144
|
+
# @return [Array] Code Scanning Alert information
|
145
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-organization
|
146
|
+
def list_code_scanning_alerts_for_org(org, options = {})
|
147
|
+
paginate "orgs/#{org}/code-scanning/alerts", options
|
148
|
+
end
|
149
|
+
|
13
150
|
# Uploads SARIF data containing the results of a code scanning analysis
|
14
151
|
#
|
15
152
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -45,7 +182,7 @@ module Octokit
|
|
45
182
|
Zlib::GzipWriter.open(tempfile) do |gz_file|
|
46
183
|
gz_file.write File.binread(file)
|
47
184
|
end
|
48
|
-
|
185
|
+
[tempfile.read].pack('m0') # Base64.strict_encode64
|
49
186
|
end
|
50
187
|
end
|
51
188
|
end
|
@@ -15,6 +15,15 @@ module Octokit
|
|
15
15
|
get "#{Repository.path repo}/codespaces/secrets/public-key"
|
16
16
|
end
|
17
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://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_codespaces_public_key(org)
|
24
|
+
get "#{Organization.path org}/codespaces/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
18
27
|
# List secrets
|
19
28
|
#
|
20
29
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -26,6 +35,17 @@ module Octokit
|
|
26
35
|
end
|
27
36
|
end
|
28
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://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_codespaces_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/codespaces/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
29
49
|
# Get a secret
|
30
50
|
#
|
31
51
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -36,6 +56,16 @@ module Octokit
|
|
36
56
|
get "#{Repository.path repo}/codespaces/secrets/#{name}"
|
37
57
|
end
|
38
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, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_codespaces_secret(org, name)
|
66
|
+
get "#{Organization.path org}/codespaces/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
39
69
|
# Create or update secrets
|
40
70
|
#
|
41
71
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -46,6 +76,16 @@ module Octokit
|
|
46
76
|
put "#{Repository.path repo}/codespaces/secrets/#{name}", options
|
47
77
|
end
|
48
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://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_codespaces_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/codespaces/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
49
89
|
# Delete a secret
|
50
90
|
#
|
51
91
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -54,6 +94,15 @@ module Octokit
|
|
54
94
|
def delete_codespaces_secret(repo, name)
|
55
95
|
boolean_from_response :delete, "#{Repository.path repo}/codespaces/secrets/#{name}"
|
56
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://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_codespaces_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/codespaces/secrets/#{name}"
|
105
|
+
end
|
57
106
|
end
|
58
107
|
end
|
59
108
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'base64'
|
4
|
-
|
5
3
|
module Octokit
|
6
4
|
class Client
|
7
5
|
# Methods for the Repo Contents API
|
@@ -80,7 +78,7 @@ module Octokit
|
|
80
78
|
end
|
81
79
|
raise ArgumentError, 'content or :file option required' if content.nil?
|
82
80
|
|
83
|
-
options[:content] = Base64.strict_encode64
|
81
|
+
options[:content] = [content].pack('m0') # Base64.strict_encode64
|
84
82
|
options[:message] = message
|
85
83
|
url = "#{Repository.path repo}/contents/#{path}"
|
86
84
|
put url, options
|
@@ -15,6 +15,15 @@ module Octokit
|
|
15
15
|
get "#{Repository.path repo}/dependabot/secrets/public-key"
|
16
16
|
end
|
17
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://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_dependabot_public_key(org)
|
24
|
+
get "#{Organization.path org}/dependabot/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
18
27
|
# List secrets
|
19
28
|
#
|
20
29
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -26,6 +35,17 @@ module Octokit
|
|
26
35
|
end
|
27
36
|
end
|
28
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://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_dependabot_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/dependabot/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
29
49
|
# Get a secret
|
30
50
|
#
|
31
51
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -36,6 +56,16 @@ module Octokit
|
|
36
56
|
get "#{Repository.path repo}/dependabot/secrets/#{name}"
|
37
57
|
end
|
38
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, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_dependabot_secret(org, name)
|
66
|
+
get "#{Organization.path org}/dependabot/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
39
69
|
# Create or update secrets
|
40
70
|
#
|
41
71
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -46,6 +76,16 @@ module Octokit
|
|
46
76
|
put "#{Repository.path repo}/dependabot/secrets/#{name}", options
|
47
77
|
end
|
48
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://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_dependabot_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/dependabot/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
49
89
|
# Delete a secret
|
50
90
|
#
|
51
91
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -54,6 +94,15 @@ module Octokit
|
|
54
94
|
def delete_dependabot_secret(repo, name)
|
55
95
|
boolean_from_response :delete, "#{Repository.path repo}/dependabot/secrets/#{name}"
|
56
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://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_dependabot_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/dependabot/secrets/#{name}"
|
105
|
+
end
|
57
106
|
end
|
58
107
|
end
|
59
108
|
end
|
@@ -22,7 +22,7 @@ module Octokit
|
|
22
22
|
# @return [Array<Sawyer::Resource>] A list of deployments
|
23
23
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployments
|
24
24
|
def deployments(repo, options = {})
|
25
|
-
|
25
|
+
paginate("#{Repository.path repo}/deployments", options)
|
26
26
|
end
|
27
27
|
alias list_deployments deployments
|
28
28
|
|
@@ -60,7 +60,7 @@ module Octokit
|
|
60
60
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
|
61
61
|
def deployment_statuses(deployment_url, options = {})
|
62
62
|
deployment = get(deployment_url, accept: options[:accept])
|
63
|
-
|
63
|
+
paginate(deployment.rels[:statuses].href, options)
|
64
64
|
end
|
65
65
|
alias list_deployment_statuses deployment_statuses
|
66
66
|
|
@@ -24,7 +24,10 @@ module Octokit
|
|
24
24
|
# @return [Sawyer::Resource] Total count of environments and list of environments
|
25
25
|
# @see https://docs.github.com/en/rest/deployments/environments#list-environments
|
26
26
|
def environments(repo, options = {})
|
27
|
-
|
27
|
+
paginate("#{Repository.path repo}/environments", options) do |data, last_response|
|
28
|
+
data.environments.concat last_response.data.environments
|
29
|
+
data.total_count += last_response.data.total_count
|
30
|
+
end
|
28
31
|
end
|
29
32
|
alias list_environments environments
|
30
33
|
|
@@ -65,7 +65,7 @@ module Octokit
|
|
65
65
|
#
|
66
66
|
# @example
|
67
67
|
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
68
|
-
# client.
|
68
|
+
# client.delete_app_token('deadbeef1234567890deadbeef987654321')
|
69
69
|
def delete_app_token(access_token, options = {})
|
70
70
|
options[:access_token] = access_token
|
71
71
|
|
@@ -197,21 +197,30 @@ module Octokit
|
|
197
197
|
# @param body [String] Comment content
|
198
198
|
# @param commit_id [String] Sha of the commit to comment on.
|
199
199
|
# @param path [String] Relative path of the file to comment on.
|
200
|
-
# @param
|
200
|
+
# @param line [Integer] Optional line index in the diff to comment on.
|
201
|
+
# For a multi-line comment, the last line of the range
|
202
|
+
# and specify 'start_line' in the 'options'.
|
203
|
+
# If not specified, the comment will be on the whole file.
|
201
204
|
# @return [Sawyer::Resource] Hash representing the new comment
|
202
205
|
# @deprecated The position will be deprecated in the next major version. Please refer to the details below.
|
203
206
|
# @see https://developer.github.com/v3/pulls/comments/#create-a-comment
|
204
207
|
# @example
|
205
208
|
# @client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
|
206
209
|
# "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
|
207
|
-
def create_pull_request_comment(repo, pull_id, body, commit_id, path,
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
210
|
+
def create_pull_request_comment(repo, pull_id, body, commit_id, path, line = nil, options = {})
|
211
|
+
comment = {
|
212
|
+
body: body,
|
213
|
+
commit_id: commit_id,
|
214
|
+
path: path
|
215
|
+
}
|
216
|
+
|
217
|
+
if line.nil?
|
218
|
+
comment[:subject_type] = 'file'
|
219
|
+
else
|
220
|
+
comment[:line] = line
|
221
|
+
end
|
222
|
+
|
223
|
+
options.merge! comment
|
215
224
|
post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
|
216
225
|
end
|
217
226
|
alias create_pull_comment create_pull_request_comment
|