octokit 4.22.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +117 -95
  3. data/Rakefile +20 -14
  4. data/lib/ext/sawyer/relation.rb +4 -2
  5. data/lib/octokit/arguments.rb +3 -3
  6. data/lib/octokit/authentication.rb +10 -3
  7. data/lib/octokit/client/actions_artifacts.rb +71 -0
  8. data/lib/octokit/client/actions_secrets.rb +111 -8
  9. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  10. data/lib/octokit/client/actions_workflow_runs.rb +23 -3
  11. data/lib/octokit/client/actions_workflows.rb +27 -2
  12. data/lib/octokit/client/apps.rb +63 -26
  13. data/lib/octokit/client/checks.rb +18 -9
  14. data/lib/octokit/client/code_scanning.rb +190 -0
  15. data/lib/octokit/client/codespaces_secrets.rb +108 -0
  16. data/lib/octokit/client/commit_branches.rb +2 -2
  17. data/lib/octokit/client/commit_comments.rb +8 -8
  18. data/lib/octokit/client/commit_pulls.rb +2 -2
  19. data/lib/octokit/client/commits.rb +25 -33
  20. data/lib/octokit/client/community_profile.rb +2 -3
  21. data/lib/octokit/client/contents.rb +19 -22
  22. data/lib/octokit/client/dependabot_secrets.rb +108 -0
  23. data/lib/octokit/client/deployments.rb +8 -8
  24. data/lib/octokit/client/downloads.rb +5 -6
  25. data/lib/octokit/client/emojis.rb +3 -3
  26. data/lib/octokit/client/environments.rb +58 -0
  27. data/lib/octokit/client/events.rb +4 -5
  28. data/lib/octokit/client/feeds.rb +4 -5
  29. data/lib/octokit/client/gists.rb +6 -6
  30. data/lib/octokit/client/gitignore.rb +3 -3
  31. data/lib/octokit/client/hooks.rb +9 -19
  32. data/lib/octokit/client/issues.rb +14 -15
  33. data/lib/octokit/client/labels.rb +10 -10
  34. data/lib/octokit/client/legacy_search.rb +3 -3
  35. data/lib/octokit/client/licenses.rb +3 -6
  36. data/lib/octokit/client/markdown.rb +3 -3
  37. data/lib/octokit/client/marketplace.rb +4 -4
  38. data/lib/octokit/client/meta.rb +4 -5
  39. data/lib/octokit/client/milestones.rb +5 -5
  40. data/lib/octokit/client/notifications.rb +6 -6
  41. data/lib/octokit/client/oauth_applications.rb +1 -7
  42. data/lib/octokit/client/objects.rb +14 -14
  43. data/lib/octokit/client/organizations.rb +100 -56
  44. data/lib/octokit/client/pages.rb +5 -7
  45. data/lib/octokit/client/projects.rb +44 -64
  46. data/lib/octokit/client/pull_requests.rb +66 -45
  47. data/lib/octokit/client/rate_limit.rb +9 -11
  48. data/lib/octokit/client/reactions.rb +62 -16
  49. data/lib/octokit/client/refs.rb +14 -17
  50. data/lib/octokit/client/releases.rb +13 -13
  51. data/lib/octokit/client/repositories.rb +92 -69
  52. data/lib/octokit/client/repository_invitations.rb +3 -3
  53. data/lib/octokit/client/reviews.rb +8 -8
  54. data/lib/octokit/client/say.rb +4 -5
  55. data/lib/octokit/client/search.rb +24 -10
  56. data/lib/octokit/client/service_status.rb +19 -9
  57. data/lib/octokit/client/source_import.rb +7 -12
  58. data/lib/octokit/client/stats.rb +10 -9
  59. data/lib/octokit/client/statuses.rb +5 -5
  60. data/lib/octokit/client/tokens.rb +31 -0
  61. data/lib/octokit/client/traffic.rb +6 -11
  62. data/lib/octokit/client/users.rb +54 -33
  63. data/lib/octokit/client.rb +42 -18
  64. data/lib/octokit/configurable.rb +51 -31
  65. data/lib/octokit/connection.rb +30 -21
  66. data/lib/octokit/default.rb +66 -35
  67. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  68. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  69. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  70. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  71. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  72. data/lib/octokit/enterprise_admin_client.rb +9 -3
  73. data/lib/octokit/enterprise_management_console_client/management_console.rb +51 -33
  74. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  75. data/lib/octokit/error.rb +51 -34
  76. data/lib/octokit/gist.rb +3 -4
  77. data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
  78. data/lib/octokit/manage_ghes_client.rb +64 -0
  79. data/lib/octokit/middleware/follow_redirects.rb +13 -12
  80. data/lib/octokit/organization.rb +3 -1
  81. data/lib/octokit/rate_limit.rb +8 -6
  82. data/lib/octokit/repo_arguments.rb +3 -4
  83. data/lib/octokit/repository.rb +32 -25
  84. data/lib/octokit/response/base_middleware.rb +10 -0
  85. data/lib/octokit/response/feed_parser.rb +5 -7
  86. data/lib/octokit/response/raise_error.rb +4 -4
  87. data/lib/octokit/user.rb +4 -2
  88. data/lib/octokit/version.rb +4 -2
  89. data/lib/octokit/warnable.rb +4 -5
  90. data/lib/octokit.rb +30 -8
  91. data/octokit.gemspec +12 -11
  92. metadata +19 -31
  93. data/lib/octokit/client/authorizations.rb +0 -182
  94. data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
  95. data/lib/octokit/preview.rb +0 -46
@@ -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
@@ -1,28 +1,49 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Actions Secrets API
5
6
  #
6
7
  # @see https://developer.github.com/v3/actions/secrets/
7
8
  module ActionsSecrets
8
-
9
9
  # Get public key for secrets encryption
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
12
12
  # @return [Hash] key_id and key
13
13
  # @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
14
- def get_public_key(repo)
14
+ def get_actions_public_key(repo)
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
18
26
 
19
27
  # List secrets
20
28
  #
21
29
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
22
30
  # @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
23
31
  # @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"
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
26
47
  end
27
48
 
28
49
  # Get a secret
@@ -31,28 +52,110 @@ module Octokit
31
52
  # @param name [String] Name of secret
32
53
  # @return [Hash] name, created_at and updated_at
33
54
  # @see https://developer.github.com/v3/actions/secrets/#get-a-secret
34
- def get_secret(repo, name)
55
+ def get_actions_secret(repo, name)
35
56
  get "#{Repository.path repo}/actions/secrets/#{name}"
36
57
  end
37
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
+
38
69
  # Create or update secrets
39
70
  #
40
71
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
41
72
  # @param name [String] Name of secret
42
73
  # @param options [Hash] encrypted_value and key_id
43
74
  # @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)
75
+ def create_or_update_actions_secret(repo, name, options)
45
76
  put "#{Repository.path repo}/actions/secrets/#{name}", options
46
77
  end
47
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
+
48
89
  # Delete a secret
49
90
  #
50
91
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
51
92
  # @param name [String] Name of secret
52
93
  # @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
53
- def delete_secret(repo, name)
94
+ def delete_actions_secret(repo, name)
54
95
  boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
55
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
56
159
  end
57
160
  end
58
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
@@ -1,5 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
5
+ # Methods for the Actions Workflows runs API
6
+ #
7
+ # @see https://docs.github.com/rest/actions/workflow-runs
3
8
  module ActionsWorkflowRuns
4
9
  # List all runs for a repository workflow
5
10
  #
@@ -13,7 +18,9 @@ module Octokit
13
18
  # @return [Sawyer::Resource] the total count and an array of workflows
14
19
  # @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
15
20
  def workflow_runs(repo, workflow, options = {})
16
- paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", 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
17
24
  end
18
25
  alias list_workflow_runs workflow_runs
19
26
 
@@ -28,7 +35,9 @@ module Octokit
28
35
  # @return [Sawyer::Resource] the total count and an array of workflows
29
36
  # @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
30
37
  def repository_workflow_runs(repo, options = {})
31
- paginate "#{Repository.path repo}/actions/runs", 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
32
41
  end
33
42
  alias list_repository_workflow_runs repository_workflow_runs
34
43
 
@@ -90,7 +99,7 @@ module Octokit
90
99
  response.headers['Location']
91
100
  end
92
101
 
93
- # Delets all log files of a workflow run
102
+ # Delete all log files of a workflow run
94
103
  #
95
104
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
96
105
  # @param id [Integer] Id of a workflow run
@@ -100,6 +109,17 @@ module Octokit
100
109
  def delete_workflow_run_logs(repo, id, options = {})
101
110
  boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
102
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
103
123
  end
104
124
  end
105
125
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
5
  # Methods for the Actions Workflows API
4
6
  #
5
7
  # @see https://developer.github.com/v3/actions/workflows
6
8
  module ActionsWorkflows
7
-
8
9
  # Get the workflows in a repository
9
10
  #
10
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -12,7 +13,9 @@ module Octokit
12
13
  # @return [Sawyer::Resource] the total count and an array of workflows
13
14
  # @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
14
15
  def workflows(repo, options = {})
15
- paginate "#{Repository.path repo}/actions/workflows", options
16
+ paginate "#{Repository.path repo}/actions/workflows", options do |data, last_response|
17
+ data.workflows.concat last_response.data.workflows
18
+ end
16
19
  end
17
20
  alias list_workflows workflows
18
21
 
@@ -38,6 +41,28 @@ module Octokit
38
41
  def workflow_dispatch(repo, id, ref, options = {})
39
42
  boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
40
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
41
66
  end
42
67
  end
43
68
  end
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Apps API
5
6
  module Apps
6
-
7
7
  # Get the authenticated App
8
8
  #
9
9
  # @param options [Hash] A customizable set of options
@@ -12,7 +12,7 @@ module Octokit
12
12
  #
13
13
  # @return [Sawyer::Resource] App information
14
14
  def app(options = {})
15
- get "app", options
15
+ get 'app', options
16
16
  end
17
17
 
18
18
  # Find all installations that belong to an App
@@ -23,16 +23,16 @@ module Octokit
23
23
  #
24
24
  # @return [Array<Sawyer::Resource>] the total_count and an array of installations
25
25
  def find_app_installations(options = {})
26
- paginate "app/installations", options
26
+ paginate 'app/installations', options
27
27
  end
28
28
  alias find_installations find_app_installations
29
29
 
30
30
  def find_integration_installations(options = {})
31
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."
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
36
  )
37
37
  find_app_installations(options)
38
38
  end
@@ -45,7 +45,7 @@ module Octokit
45
45
  #
46
46
  # @return [Sawyer::Resource] the total_count and an array of installations
47
47
  def find_user_installations(options = {})
48
- paginate("user/installations", options) do |data, last_response|
48
+ paginate('user/installations', options) do |data, last_response|
49
49
  data.installations.concat last_response.data.installations
50
50
  end
51
51
  end
@@ -76,10 +76,10 @@ module Octokit
76
76
 
77
77
  def create_integration_installation_access_token(installation, options = {})
78
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."
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
83
  )
84
84
  create_app_installation_access_token(installation, options)
85
85
  end
@@ -128,7 +128,7 @@ module Octokit
128
128
  #
129
129
  # @return [Sawyer::Resource] the total_count and an array of repositories
130
130
  def list_app_installation_repositories(options = {})
131
- paginate("installation/repositories", options) do |data, last_response|
131
+ paginate('installation/repositories', options) do |data, last_response|
132
132
  data.repositories.concat last_response.data.repositories
133
133
  end
134
134
  end
@@ -136,10 +136,10 @@ module Octokit
136
136
 
137
137
  def list_integration_installation_repositories(options = {})
138
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."
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
143
  )
144
144
  list_app_installation_repositories(options)
145
145
  end
@@ -160,10 +160,10 @@ module Octokit
160
160
 
161
161
  def add_repository_to_integration_installation(installation, repo, options = {})
162
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."
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
167
  )
168
168
  add_repository_to_app_installation(installation, repo, options)
169
169
  end
@@ -184,10 +184,10 @@ module Octokit
184
184
 
185
185
  def remove_repository_from_integration_installation(installation, repo, options = {})
186
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."
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
191
  )
192
192
  remove_repository_from_app_installation(installation, repo, options)
193
193
  end
@@ -217,6 +217,43 @@ module Octokit
217
217
  def delete_installation(installation, options = {})
218
218
  boolean_from_response :delete, "app/installations/#{installation}", options
219
219
  end
220
+
221
+ # Returns a list of webhook deliveries for the webhook configured for a GitHub App.
222
+ #
223
+ # @param options [Hash] A customizable set of options
224
+ #
225
+ # @see https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook
226
+ #
227
+ # @return [Array<Hash>] an array of hook deliveries
228
+ def list_app_hook_deliveries(options = {})
229
+ paginate('app/hook/deliveries', options) do |data, last_response|
230
+ data.concat last_response.data
231
+ end
232
+ end
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
+
246
+ # Redeliver a delivery for the webhook configured for a GitHub App.
247
+ #
248
+ # @param delivery_id [Integer] The id of a GitHub App Hook Delivery
249
+ # @param options [Hash] A customizable set of options
250
+ #
251
+ # @see https://developer.github.com/v3/apps/#redeliver-a-delivery-for-an-app-webhook
252
+ #
253
+ # @return [Boolean] Success
254
+ def deliver_app_hook(delivery_id, options = {})
255
+ boolean_from_response :post, "app/hook/deliveries/#{delivery_id}/attempts", options
256
+ end
220
257
  end
221
258
  end
222
259
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Checks API
5
6
  #
6
7
  # @see https://developer.github.com/v3/checks/
7
8
  module Checks
8
-
9
9
  # Methods for Check Runs
10
10
  #
11
11
  # @see https://developer.github.com/v3/checks/runs/
@@ -60,9 +60,12 @@ module Octokit
60
60
  # result.check_runs[0].id # => 51295429
61
61
  # result.check_runs[0].status # => "in_progress"
62
62
  def check_runs_for_ref(repo, ref, options = {})
63
- get "#{Repository.path repo}/commits/#{ref}/check-runs", options
63
+ paginate "#{Repository.path repo}/commits/#{ref}/check-runs", options do |data, last_response|
64
+ data.check_runs.concat last_response.data.check_runs
65
+ data.total_count += last_response.data.total_count
66
+ end
64
67
  end
65
- alias :list_check_runs_for_ref :check_runs_for_ref
68
+ alias list_check_runs_for_ref check_runs_for_ref
66
69
 
67
70
  # List check runs in a check suite
68
71
  #
@@ -81,9 +84,12 @@ module Octokit
81
84
  # result.check_runs[0].check_suite.id # => 50440400
82
85
  # result.check_runs[0].status # => "in_progress"
83
86
  def check_runs_for_check_suite(repo, id, options = {})
84
- get "#{Repository.path repo}/check-suites/#{id}/check-runs", options
87
+ paginate "#{Repository.path repo}/check-suites/#{id}/check-runs", options do |data, last_response|
88
+ data.check_runs.concat last_response.data.check_runs
89
+ data.total_count += last_response.data.total_count
90
+ end
85
91
  end
86
- alias :list_check_runs_for_check_suite :check_runs_for_check_suite
92
+ alias list_check_runs_for_check_suite check_runs_for_check_suite
87
93
 
88
94
  # Get a single check run
89
95
  #
@@ -107,7 +113,7 @@ module Octokit
107
113
  # annotations[0].path # => "README.md"
108
114
  # annotations[0].message # => "Looks good!"
109
115
  def check_run_annotations(repo, id, options = {})
110
- get "#{Repository.path repo}/check-runs/#{id}/annotations", options
116
+ paginate "#{Repository.path repo}/check-runs/#{id}/annotations", options
111
117
  end
112
118
 
113
119
  # Methods for Check Suites
@@ -140,9 +146,12 @@ module Octokit
140
146
  # result.check_suites[0].id # => 50440400
141
147
  # result.check_suites[0].app.id # => 76765
142
148
  def check_suites_for_ref(repo, ref, options = {})
143
- get "#{Repository.path repo}/commits/#{ref}/check-suites", options
149
+ paginate "#{Repository.path repo}/commits/#{ref}/check-suites", options do |data, last_response|
150
+ data.check_suites.concat last_response.data.check_suites
151
+ data.total_count += last_response.data.total_count
152
+ end
144
153
  end
145
- alias :list_check_suites_for_ref :check_suites_for_ref
154
+ alias list_check_suites_for_ref check_suites_for_ref
146
155
 
147
156
  # Set preferences for check suites on a repository
148
157
  #