octokit 4.13.0 → 4.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +14 -13
- data/README.md +38 -12
- data/lib/octokit/authentication.rb +2 -11
- data/lib/octokit/client.rb +21 -10
- data/lib/octokit/client/actions_secrets.rb +58 -0
- data/lib/octokit/client/actions_workflow_runs.rb +94 -0
- data/lib/octokit/client/actions_workflows.rb +43 -0
- data/lib/octokit/client/apps.rb +34 -8
- data/lib/octokit/client/authorizations.rb +2 -70
- data/lib/octokit/client/checks.rb +211 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/events.rb +1 -0
- data/lib/octokit/client/issues.rb +7 -2
- data/lib/octokit/client/oauth_applications.rb +122 -0
- data/lib/octokit/client/organizations.rb +24 -10
- data/lib/octokit/client/projects.rb +1 -1
- data/lib/octokit/client/pull_requests.rb +1 -1
- data/lib/octokit/client/refs.rb +7 -3
- data/lib/octokit/client/repositories.rb +47 -10
- data/lib/octokit/client/repository_invitations.rb +1 -1
- data/lib/octokit/client/reviews.rb +18 -0
- data/lib/octokit/client/search.rb +1 -1
- data/lib/octokit/client/users.rb +86 -0
- data/lib/octokit/connection.rb +14 -3
- data/lib/octokit/error.rb +33 -1
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/preview.rb +9 -1
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/repository.rb +1 -1
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +2 -1
- metadata +34 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9801b25dfdd07e517b87bdc1404ffa64fd12496b66af8bb8bc4af57f6f33483f
|
4
|
+
data.tar.gz: b082dcc32f514846b53da5aaafe7666020c9de8d590dafb6e93743767a70573b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16595560313f6346448710adf2a0d641fe62521089ff017aff1c2f1dc6dd1d5dc06d8397e552a098cf1a6ada91edfa111863d9c4491df86d3d38d3143531a7b5
|
7
|
+
data.tar.gz: 7dc816349c9050b31e0c0d09a7e1e25b6d455d59f6ae817db2f46b16900104bcdff15d3f280352e7bcb0ca195060824094ebe09ea022c3e46b52c8f559c0cc5b
|
data/CONTRIBUTING.md
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
## Submitting a Pull Request
|
2
2
|
|
3
|
-
0.
|
4
|
-
|
5
|
-
|
6
|
-
2. [
|
7
|
-
3.
|
8
|
-
4.
|
9
|
-
5.
|
10
|
-
6.
|
11
|
-
7. Run `
|
3
|
+
0. Read our [Code of Conduct](CODE_OF_CONDUCT.md).
|
4
|
+
1. Check out [Hacking on Octokit](README.md#hacking-on-octokitrb) in the
|
5
|
+
README for bootstrapping the project for local development.
|
6
|
+
2. [Fork the repository.][fork]
|
7
|
+
3. [Create a topic branch.][branch]
|
8
|
+
4. Add specs for your unimplemented feature or bug fix.
|
9
|
+
5. Run `script/test`. If your specs pass, return to step 3.
|
10
|
+
6. Implement your feature or bug fix.
|
11
|
+
7. Run `script/test`. If your specs fail, return to step 5.
|
12
|
+
8. Run `open coverage/index.html`. If your changes are not completely covered
|
12
13
|
by your tests, return to step 4.
|
13
|
-
|
14
|
-
|
14
|
+
9. Add documentation for your feature or bug fix.
|
15
|
+
10. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
|
15
16
|
back to step 8.
|
16
|
-
|
17
|
+
11. Add, commit, and push your changes. For documentation-only fixes, please
|
17
18
|
add "[ci skip]" to your commit message to avoid needless CI builds.
|
18
|
-
|
19
|
+
12. [Submit a pull request.][pr]
|
19
20
|
|
20
21
|
[fork]: https://help.github.com/articles/fork-a-repo
|
21
22
|
[branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
|
data/README.md
CHANGED
@@ -30,6 +30,7 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
30
30
|
10. [Configuration and defaults](#configuration-and-defaults)
|
31
31
|
1. [Configuring module defaults](#configuring-module-defaults)
|
32
32
|
2. [Using ENV variables](#using-env-variables)
|
33
|
+
3. [Timeouts](#timeouts)
|
33
34
|
11. [Hypermedia agent](#hypermedia-agent)
|
34
35
|
1. [Hypermedia in Octokit](#hypermedia-in-octokit)
|
35
36
|
2. [URI templates](#uri-templates)
|
@@ -40,7 +41,8 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
40
41
|
1. [Debugging](#debugging)
|
41
42
|
2. [Caching](#caching)
|
42
43
|
14. [Hacking on Octokit.rb](#hacking-on-octokitrb)
|
43
|
-
1. [
|
44
|
+
1. [Code of Conduction](#code_of_conduct)
|
45
|
+
2. [Running and writing new tests](#running-and-writing-new-tests)
|
44
46
|
15. [Supported Ruby Versions](#supported-ruby-versions)
|
45
47
|
16. [Versioning](#versioning)
|
46
48
|
17. [Making Repeating Requests](#making-repeating-requests)
|
@@ -62,7 +64,7 @@ client.readme 'al3x/sovereign', :accept => 'application/vnd.github.html'
|
|
62
64
|
```
|
63
65
|
|
64
66
|
[wrappers]: http://wynnnetherland.com/journal/what-makes-a-good-api-wrapper
|
65
|
-
[github-api]:
|
67
|
+
[github-api]: https://developer.github.com/v3/
|
66
68
|
|
67
69
|
## Quick start
|
68
70
|
|
@@ -288,7 +290,7 @@ link relations](#hypermedia-agent).
|
|
288
290
|
|
289
291
|
```ruby
|
290
292
|
issues = client.issues 'rails/rails'
|
291
|
-
issues.concat client.last_response.rels[:next].
|
293
|
+
issues.concat client.get(client.last_response.rels[:next].href)
|
292
294
|
```
|
293
295
|
|
294
296
|
### Auto pagination
|
@@ -427,6 +429,27 @@ Deprecation warnings and API endpoints in development preview warnings are
|
|
427
429
|
printed to STDOUT by default, these can be disabled by setting the ENV
|
428
430
|
`OCTOKIT_SILENT=true`.
|
429
431
|
|
432
|
+
### Timeouts
|
433
|
+
|
434
|
+
By default, Octokit does not timeout network requests. To set a timeout, pass in Faraday timeout settings to Octokit's `connection_options` setting.
|
435
|
+
|
436
|
+
```ruby
|
437
|
+
Octokit.configure do |c|
|
438
|
+
c.api_endpoint = ENV.fetch('GITHUB_API_ENDPOINT', 'https://api.github.com/')
|
439
|
+
c.connection_options = {
|
440
|
+
request: {
|
441
|
+
open_timeout: 5,
|
442
|
+
timeout: 5
|
443
|
+
}
|
444
|
+
}
|
445
|
+
end
|
446
|
+
```
|
447
|
+
You should set a timeout in order to avoid Ruby’s Timeout module, which can hose your server. Here are some resources for more information on this:
|
448
|
+
|
449
|
+
- [The Oldest Bug In Ruby - Why Rack::Timeout Might Hose your Server](https://www.schneems.com/2017/02/21/the-oldest-bug-in-ruby-why-racktimeout-might-hose-your-server/)
|
450
|
+
- [Timeout: Ruby's Most Dangerous API](https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/)
|
451
|
+
- [The Ultimate Guide to Ruby Timeouts](https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts)
|
452
|
+
|
430
453
|
## Hypermedia agent
|
431
454
|
|
432
455
|
Starting in version 2.0, Octokit is [hypermedia][]-enabled. Under the hood,
|
@@ -628,9 +651,15 @@ to run a Ruby console to poke on Octokit, you can crank one up with:
|
|
628
651
|
|
629
652
|
script/console
|
630
653
|
|
631
|
-
Using the scripts in `./
|
654
|
+
Using the scripts in `./script` instead of `bundle exec rspec`, `bundle
|
632
655
|
console`, etc. ensures your dependencies are up-to-date.
|
633
656
|
|
657
|
+
### Code of Conduct
|
658
|
+
|
659
|
+
We want both the Octokit.rb and larger Octokit communities to be an open
|
660
|
+
and welcoming environments. Please read and follow both in spirit and
|
661
|
+
letter [Code of Conduct](CODE_OF_CONDUCT.md).
|
662
|
+
|
634
663
|
### Running and writing new tests
|
635
664
|
|
636
665
|
Octokit uses [VCR][] for recording and playing back API fixtures during test
|
@@ -684,15 +713,12 @@ when writing new specs.
|
|
684
713
|
|
685
714
|
## Supported Ruby Versions
|
686
715
|
|
687
|
-
This library aims to support and is [tested against][
|
716
|
+
This library aims to support and is [tested against][actions] the following Ruby
|
688
717
|
implementations:
|
689
718
|
|
690
|
-
* Ruby 2.0
|
691
|
-
* Ruby 2.1
|
692
|
-
* Ruby 2.2
|
693
|
-
* Ruby 2.3
|
694
|
-
* Ruby 2.4
|
695
719
|
* Ruby 2.5
|
720
|
+
* Ruby 2.6
|
721
|
+
* Ruby 2.7
|
696
722
|
|
697
723
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
698
724
|
|
@@ -707,7 +733,7 @@ implementation, you will be responsible for providing patches in a timely
|
|
707
733
|
fashion. If critical issues for a particular implementation exist at the time
|
708
734
|
of a major release, support for that Ruby version may be dropped.
|
709
735
|
|
710
|
-
[
|
736
|
+
[actions]: https://github.com/octokit/octokit.rb/actions
|
711
737
|
|
712
738
|
## Versioning
|
713
739
|
|
@@ -729,7 +755,7 @@ The changes made between versions can be seen on the [project releases page][rel
|
|
729
755
|
[releases]: https://github.com/octokit/octokit.rb/releases
|
730
756
|
|
731
757
|
## Making Repeating Requests
|
732
|
-
In most cases it would be best to use a [webhooks](https://developer.github.com/webhooks/), but sometimes webhooks don't provide all of the information needed. In those cases where one might need to poll for progress or retry a request on failure, we designed [Octopoller](https://github.com/octokit/octopoller.rb). Octopoller is a micro gem perfect for making repeating requests.
|
758
|
+
In most cases it would be best to use a [webhooks](https://developer.github.com/webhooks/), but sometimes webhooks don't provide all of the information needed. In those cases where one might need to poll for progress or retry a request on failure, we designed [Octopoller](https://github.com/octokit/octopoller.rb). Octopoller is a micro gem perfect for making repeating requests.
|
733
759
|
|
734
760
|
```ruby
|
735
761
|
Octopoller.poll(timeout: 15.seconds) do
|
@@ -43,22 +43,13 @@ module Octokit
|
|
43
43
|
# requests at a higher rate limit
|
44
44
|
#
|
45
45
|
# @see https://developer.github.com/v3/#unauthenticated-rate-limited-requests
|
46
|
-
# @return Boolean
|
46
|
+
# @return [Boolean]
|
47
47
|
def application_authenticated?
|
48
|
-
!!
|
48
|
+
!!(@client_id && @client_secret)
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
def application_authentication
|
54
|
-
if @client_id && @client_secret
|
55
|
-
{
|
56
|
-
:client_id => @client_id,
|
57
|
-
:client_secret => @client_secret
|
58
|
-
}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
53
|
def login_from_netrc
|
63
54
|
return unless netrc?
|
64
55
|
|
data/lib/octokit/client.rb
CHANGED
@@ -10,10 +10,16 @@ require 'octokit/repository'
|
|
10
10
|
require 'octokit/user'
|
11
11
|
require 'octokit/organization'
|
12
12
|
require 'octokit/preview'
|
13
|
+
require 'octokit/client/actions_secrets'
|
14
|
+
require 'octokit/client/actions_workflows'
|
15
|
+
require 'octokit/client/actions_workflow_runs'
|
13
16
|
require 'octokit/client/apps'
|
14
17
|
require 'octokit/client/authorizations'
|
18
|
+
require 'octokit/client/checks'
|
15
19
|
require 'octokit/client/commits'
|
16
20
|
require 'octokit/client/commit_comments'
|
21
|
+
require 'octokit/client/commit_pulls'
|
22
|
+
require 'octokit/client/commit_branches'
|
17
23
|
require 'octokit/client/community_profile'
|
18
24
|
require 'octokit/client/contents'
|
19
25
|
require 'octokit/client/downloads'
|
@@ -33,6 +39,7 @@ require 'octokit/client/markdown'
|
|
33
39
|
require 'octokit/client/marketplace'
|
34
40
|
require 'octokit/client/milestones'
|
35
41
|
require 'octokit/client/notifications'
|
42
|
+
require 'octokit/client/oauth_applications'
|
36
43
|
require 'octokit/client/objects'
|
37
44
|
require 'octokit/client/organizations'
|
38
45
|
require 'octokit/client/pages'
|
@@ -68,9 +75,13 @@ module Octokit
|
|
68
75
|
include Octokit::Connection
|
69
76
|
include Octokit::Preview
|
70
77
|
include Octokit::Warnable
|
78
|
+
include Octokit::Client::ActionsSecrets
|
71
79
|
include Octokit::Client::Authorizations
|
80
|
+
include Octokit::Client::Checks
|
72
81
|
include Octokit::Client::Commits
|
73
82
|
include Octokit::Client::CommitComments
|
83
|
+
include Octokit::Client::CommitPulls
|
84
|
+
include Octokit::Client::CommitBranches
|
74
85
|
include Octokit::Client::CommunityProfile
|
75
86
|
include Octokit::Client::Contents
|
76
87
|
include Octokit::Client::Deployments
|
@@ -81,6 +92,8 @@ module Octokit
|
|
81
92
|
include Octokit::Client::Gists
|
82
93
|
include Octokit::Client::Gitignore
|
83
94
|
include Octokit::Client::Hooks
|
95
|
+
include Octokit::Client::ActionsWorkflows
|
96
|
+
include Octokit::Client::ActionsWorkflowRuns
|
84
97
|
include Octokit::Client::Apps
|
85
98
|
include Octokit::Client::Issues
|
86
99
|
include Octokit::Client::Labels
|
@@ -91,6 +104,7 @@ module Octokit
|
|
91
104
|
include Octokit::Client::Marketplace
|
92
105
|
include Octokit::Client::Milestones
|
93
106
|
include Octokit::Client::Notifications
|
107
|
+
include Octokit::Client::OauthApplications
|
94
108
|
include Octokit::Client::Objects
|
95
109
|
include Octokit::Client::Organizations
|
96
110
|
include Octokit::Client::Pages
|
@@ -119,7 +133,8 @@ module Octokit
|
|
119
133
|
def initialize(options = {})
|
120
134
|
# Use options passed in, but fall back to module defaults
|
121
135
|
Octokit::Configurable.keys.each do |key|
|
122
|
-
|
136
|
+
value = options.key?(key) ? options[key] : Octokit.instance_variable_get(:"@#{key}")
|
137
|
+
instance_variable_set(:"@#{key}", value)
|
123
138
|
end
|
124
139
|
|
125
140
|
login_from_netrc unless user_authenticated? || application_authenticated?
|
@@ -132,16 +147,12 @@ module Octokit
|
|
132
147
|
inspected = super
|
133
148
|
|
134
149
|
# mask password
|
135
|
-
inspected
|
136
|
-
inspected
|
137
|
-
inspected
|
150
|
+
inspected.gsub! @password, '*******' if @password
|
151
|
+
inspected.gsub! @management_console_password, '*******' if @management_console_password
|
152
|
+
inspected.gsub! @bearer_token, '********' if @bearer_token
|
138
153
|
# Only show last 4 of token, secret
|
139
|
-
if @access_token
|
140
|
-
|
141
|
-
end
|
142
|
-
if @client_secret
|
143
|
-
inspected = inspected.gsub! @client_secret, "#{'*'*36}#{@client_secret[36..-1]}"
|
144
|
-
end
|
154
|
+
inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}" if @access_token
|
155
|
+
inspected.gsub! @client_secret, "#{'*'*36}#{@client_secret[36..-1]}" if @client_secret
|
145
156
|
|
146
157
|
inspected
|
147
158
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Methods for the Actions Secrets API
|
5
|
+
#
|
6
|
+
# @see https://developer.github.com/v3/actions/secrets/
|
7
|
+
module ActionsSecrets
|
8
|
+
|
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
|
+
|
19
|
+
# List secrets
|
20
|
+
#
|
21
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
22
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
23
|
+
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
|
24
|
+
def list_secrets(repo)
|
25
|
+
paginate "#{Repository.path repo}/actions/secrets"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get a secret
|
29
|
+
#
|
30
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
31
|
+
# @param name [String] Name of secret
|
32
|
+
# @return [Hash] name, created_at and updated_at
|
33
|
+
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
34
|
+
def get_secret(repo, name)
|
35
|
+
get "#{Repository.path repo}/actions/secrets/#{name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create or update secrets
|
39
|
+
#
|
40
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
41
|
+
# @param name [String] Name of secret
|
42
|
+
# @param options [Hash] encrypted_value and key_id
|
43
|
+
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
44
|
+
def create_or_update_secret(repo, name, options)
|
45
|
+
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delete a secret
|
49
|
+
#
|
50
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
51
|
+
# @param name [String] Name of secret
|
52
|
+
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
53
|
+
def delete_secret(repo, name)
|
54
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
module ActionsWorkflowRuns
|
4
|
+
# List all runs for a repository workflow
|
5
|
+
#
|
6
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
7
|
+
# @param workflow [Integer, String] Id or file name of the workflow
|
8
|
+
# @option options [String] :actor Optional filtering by a user
|
9
|
+
# @option options [String] :branch Optional filtering by a branch
|
10
|
+
# @option options [String] :event Optional filtering by the event type
|
11
|
+
# @option options [String] :status Optional filtering by a status or conclusion
|
12
|
+
#
|
13
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
14
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
|
15
|
+
def workflow_runs(repo, workflow, options = {})
|
16
|
+
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options
|
17
|
+
end
|
18
|
+
alias list_workflow_runs workflow_runs
|
19
|
+
|
20
|
+
# List all workflow runs for a repository
|
21
|
+
#
|
22
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
23
|
+
# @option options [String] :actor Optional filtering by the login of a user
|
24
|
+
# @option options [String] :branch Optional filtering by a branch
|
25
|
+
# @option options [String] :event Optional filtering by the event type (e.g. push, pull_request, issue)
|
26
|
+
# @option options [String] :status Optional filtering by a status or conclusion (e.g. success, completed...)
|
27
|
+
#
|
28
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
29
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
|
30
|
+
def repository_workflow_runs(repo, options = {})
|
31
|
+
paginate "#{Repository.path repo}/actions/runs", options
|
32
|
+
end
|
33
|
+
alias list_repository_workflow_runs repository_workflow_runs
|
34
|
+
|
35
|
+
# Get a workflow run
|
36
|
+
#
|
37
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
38
|
+
# @param id [Integer] Id of a workflow run
|
39
|
+
#
|
40
|
+
# @return [Sawyer::Resource] Run information
|
41
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
42
|
+
def workflow_run(repo, id, options = {})
|
43
|
+
get "#{Repository.path repo}/actions/runs/#{id}", options
|
44
|
+
end
|
45
|
+
|
46
|
+
# Re-runs a workflow run
|
47
|
+
#
|
48
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
49
|
+
# @param id [Integer] Id of a workflow run
|
50
|
+
#
|
51
|
+
# @return [Boolean] Returns true if the re-run request was accepted
|
52
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
53
|
+
def rerun_workflow_run(repo, id, options = {})
|
54
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/rerun", options
|
55
|
+
end
|
56
|
+
|
57
|
+
# Cancels a workflow run
|
58
|
+
#
|
59
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
60
|
+
# @param id [Integer] Id of a workflow run
|
61
|
+
#
|
62
|
+
# @return [Boolean] Returns true if the cancellation was accepted
|
63
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
64
|
+
def cancel_workflow_run(repo, id, options = {})
|
65
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/cancel", options
|
66
|
+
end
|
67
|
+
|
68
|
+
# Get a download url for archived log files of a workflow run
|
69
|
+
#
|
70
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
71
|
+
# @param id [Integer] Id of a workflow run
|
72
|
+
#
|
73
|
+
# @return [String] URL to the archived log files of the run
|
74
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
75
|
+
def workflow_run_logs(repo, id, options = {})
|
76
|
+
url = "#{Repository.path repo}/actions/runs/#{id}/logs"
|
77
|
+
|
78
|
+
response = client_without_redirects.head(url, options)
|
79
|
+
response.headers['Location']
|
80
|
+
end
|
81
|
+
|
82
|
+
# Delets all log files of a workflow run
|
83
|
+
#
|
84
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
85
|
+
# @param id [Integer] Id of a workflow run
|
86
|
+
#
|
87
|
+
# @return [Boolean] Returns true if the logs are deleted
|
88
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
89
|
+
def delete_workflow_run_logs(repo, id, options = {})
|
90
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
# Methods for the Actions Workflows API
|
4
|
+
#
|
5
|
+
# @see https://developer.github.com/v3/actions/workflows
|
6
|
+
module ActionsWorkflows
|
7
|
+
|
8
|
+
# Get the workflows in a repository
|
9
|
+
#
|
10
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
11
|
+
#
|
12
|
+
# @return [Sawyer::Resource] the total count and an array of workflows
|
13
|
+
# @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
14
|
+
def workflows(repo, options = {})
|
15
|
+
paginate "#{Repository.path repo}/actions/workflows", options
|
16
|
+
end
|
17
|
+
alias list_workflows workflows
|
18
|
+
|
19
|
+
# Get single workflow in a repository
|
20
|
+
#
|
21
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
22
|
+
# @param id [Integer, String] Id or file name of the workflow
|
23
|
+
#
|
24
|
+
# @return [Sawyer::Resource] A single workflow
|
25
|
+
# @see https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
26
|
+
def workflow(repo, id, options = {})
|
27
|
+
get "#{Repository.path repo}/actions/workflows/#{id}", options
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create a workflow dispatch event
|
31
|
+
#
|
32
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
33
|
+
# @param id [Integer, String] Id or file name of the workflow
|
34
|
+
# @param ref [String] A SHA, branch name, or tag name
|
35
|
+
#
|
36
|
+
# @return [Boolean] True if event was dispatched, false otherwise
|
37
|
+
# @see https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
|
38
|
+
def workflow_dispatch(repo, id, ref, options = {})
|
39
|
+
boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|