Skip to content

Commit

Permalink
Merge branch 'main' into v8
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfloyd authored Oct 16, 2024
2 parents 8532300 + c0ce2e5 commit 9f1a057
Show file tree
Hide file tree
Showing 110 changed files with 15,868 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add_to_octokit_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/add-to-project@v0.5.0
- uses: actions/add-to-project@v1.0.2
with:
project-url: https://github.com/orgs/octokit/projects/10
github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -71,4 +71,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
8 changes: 4 additions & 4 deletions .github/workflows/immediate-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ on:
issues:
types:
- opened
pull_request:
pull_request_target:
types:
- opened
jobs:
respond-to-issue:
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' && github.actor != 'githubactions[bot]' && github.actor != 'octokitbot' }}
runs-on: ubuntu-latest
steps:
- name: Determine issue or PR number
id: extract
run: echo "NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"

- name: Respond to issue or PR
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.extract.outputs.NUMBER }}
body: >
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday!
We have a [process in place](https://github.com/octokit/.github/blob/main/community/prioritization_response.md#overview) for prioritizing and responding to your input.
Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with `Status: Up for grabs`.
Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with `Status: Up for grabs`.
You & others like you are the reason all of this works! So thank you & happy coding! 🚀
3 changes: 2 additions & 1 deletion .github/workflows/octokit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- "3.0"
- "3.1"
- "3.2"
- "3.3"
- head
faraday:
- ~> 1.0
Expand All @@ -30,7 +31,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Cache Ruby dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ./.bundle/gems
key: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: >
👋 Hey Friends, this issue has been automatically marked as `stale` because it has no recent activity.
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ group :test do
gem 'rexml', '>= 3.2.4'
end
gem 'faraday-http-cache', '~> 2.5', '>= 2.5.1'
gem 'base64'
gem 'json', '>= 2.3.0'
gem 'jwt', '~> 2.2', '>= 2.2.1'
gem 'mime-types', '~> 3.3', '>= 3.3.1'
Expand Down Expand Up @@ -48,7 +49,7 @@ group :test, :development do
gem 'bundler', '>= 1', '< 3'
gem 'pry-byebug'
gem 'redcarpet'
gem 'rubocop', '1.57.1'
gem 'rubocop', '1.66.1'
end

gemspec
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Install via Rubygems

... or add to your Gemfile

gem "octokit", "~> 5.0"
gem "octokit"

Access the library in Ruby:

Expand Down Expand Up @@ -709,6 +709,9 @@ Octokit:
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password. |
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname. |
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint. |
| `OCTOKIT_TEST_GITHUB_MANAGE_GHES_ENDPOINT` | GitHub Enterprise Server GHES Manage Endpoint. |
| `OCTOKIT_TEST_GITHUB_MANAGE_GHES_USERNAME` | GitHub Enterprise Server GHES Manage Username. |
| `OCTOKIT_TEST_GITHUB_MANAGE_GHES_PASSWORD` | GitHub Enterprise Server GHES Manage Password. |
| `OCTOKIT_TEST_GITHUB_INTEGRATION` | [GitHub Integration](https://developer.github.com/early-access/integrations/) owned by your test organization. |
| `OCTOKIT_TEST_GITHUB_INTEGRATION_INSTALLATION` | Installation of the GitHub Integration specified above. |
| `OCTOKIT_TEST_INTEGRATION_PEM_KEY` | File path to the private key generated from your integration. |
Expand Down Expand Up @@ -738,6 +741,7 @@ implementations:
* Ruby 3.0
* Ruby 3.1
* Ruby 3.2
* Ruby 3.3

If something doesn't work on one of these Ruby versions, it's a bug.

Expand Down
17 changes: 16 additions & 1 deletion lib/octokit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'octokit/client'
require 'octokit/enterprise_admin_client'
require 'octokit/enterprise_management_console_client'
require 'octokit/manage_ghes_client'

# Ruby toolkit for the GitHub API
module Octokit
Expand Down Expand Up @@ -41,12 +42,24 @@ def enterprise_management_console_client
@enterprise_management_console_client = Octokit::EnterpriseManagementConsoleClient.new(options)
end

# ManageGHESClient client based on configured options {Configurable}
#
# @return [Octokit::ManageGHESClient] API wrapper
def manage_ghes_client
if defined?(@manage_ghes_client) && @manage_ghes_client.same_options?(options)
return @manage_ghes_client
end

@manage_ghes_client = Octokit::ManageGHESClient.new(options)
end

private

def respond_to_missing?(method_name, include_private = false)
client.respond_to?(method_name, include_private) ||
enterprise_admin_client.respond_to?(method_name, include_private) ||
enterprise_management_console_client.respond_to?(method_name, include_private)
enterprise_management_console_client.respond_to?(method_name, include_private) ||
manage_ghes_client.respond_to?(method_name, include_private)
end

def method_missing(method_name, *args, &block)
Expand All @@ -56,6 +69,8 @@ def method_missing(method_name, *args, &block)
return enterprise_admin_client.send(method_name, *args, &block)
elsif enterprise_management_console_client.respond_to?(method_name)
return enterprise_management_console_client.send(method_name, *args, &block)
elsif manage_ghes_client.respond_to?(method_name)
return manage_ghes_client.send(method_name, *args, &block)
end

super
Expand Down
2 changes: 1 addition & 1 deletion lib/octokit/arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Arguments < Array

def initialize(args)
@options = args.last.is_a?(::Hash) ? args.pop : {}
super(args)
super
end
end
end
2 changes: 0 additions & 2 deletions lib/octokit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
require 'octokit/client/organizations'
require 'octokit/client/pages'
require 'octokit/client/projects'
require 'octokit/client/pub_sub_hubbub'
require 'octokit/client/pull_requests'
require 'octokit/client/rate_limit'
require 'octokit/client/reactions'
Expand Down Expand Up @@ -118,7 +117,6 @@ class Client
include Octokit::Client::Organizations
include Octokit::Client::Pages
include Octokit::Client::Projects
include Octokit::Client::PubSubHubbub
include Octokit::Client::PullRequests
include Octokit::Client::RateLimit
include Octokit::Client::Reactions
Expand Down
49 changes: 49 additions & 0 deletions lib/octokit/client/actions_secrets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ def get_actions_public_key(repo)
get "#{Repository.path repo}/actions/secrets/public-key"
end

# Get public key for secrets encryption
#
# @param org [String] A GitHub organization
# @return [Hash] key_id and key
# @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
def get_org_actions_public_key(org)
get "#{Organization.path org}/actions/secrets/public-key"
end

# List secrets
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
Expand All @@ -26,6 +35,17 @@ def list_actions_secrets(repo)
end
end

# List org secrets
#
# @param org [String] A GitHub organization
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
# @see https://developer.github.com/v3/actions/secrets/#list-organization-secrets
def list_org_actions_secrets(org)
paginate "#{Organization.path org}/actions/secrets" do |data, last_response|
data.secrets.concat last_response.data.secrets
end
end

# Get a secret
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
Expand All @@ -36,6 +56,16 @@ def get_actions_secret(repo, name)
get "#{Repository.path repo}/actions/secrets/#{name}"
end

# Get an org secret
#
# @param org [String] A GitHub organization
# @param name [String] Name of secret
# @return [Hash] name, created_at and updated_at
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
def get_org_actions_secret(org, name)
get "#{Organization.path org}/actions/secrets/#{name}"
end

# Create or update secrets
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
Expand All @@ -46,6 +76,16 @@ def create_or_update_actions_secret(repo, name, options)
put "#{Repository.path repo}/actions/secrets/#{name}", options
end

# Create or update org secrets
#
# @param org [String] A GitHub organization
# @param name [String] Name of secret
# @param options [Hash] encrypted_value and key_id
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret
def create_or_update_org_actions_secret(org, name, options)
put "#{Organization.path org}/actions/secrets/#{name}", options
end

# Delete a secret
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
Expand All @@ -55,6 +95,15 @@ def delete_actions_secret(repo, name)
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
end

# Delete an org secret
#
# @param org [String] A GitHub organization
# @param name [String] Name of secret
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret
def delete_org_actions_secret(org, name)
boolean_from_response :delete, "#{Organization.path org}/actions/secrets/#{name}"
end

# Get environment public key for secrets encryption
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
Expand Down
12 changes: 12 additions & 0 deletions lib/octokit/client/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ def list_app_hook_deliveries(options = {})
end
end

# Returns a delivery for the webhook configured for a GitHub App.
#
# @param delivery_id [String] The id of a GitHub App Hook Delivery
# @param options [Hash] A customizable set of options
#
# @see https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook
#
# @return [<Sawyer::Resource>] The webhook delivery
def app_hook_delivery(delivery_id, options = {})
get "/app/hook/deliveries/#{delivery_id}", options
end

# Redeliver a delivery for the webhook configured for a GitHub App.
#
# @param delivery_id [Integer] The id of a GitHub App Hook Delivery
Expand Down
Loading

0 comments on commit 9f1a057

Please sign in to comment.