-
Notifications
You must be signed in to change notification settings - Fork 91
Add support for enterprise level GitHub Apps #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for generating GitHub App tokens for enterprise-level installations, allowing GitHub Apps to authenticate with enterprise management APIs. The implementation includes comprehensive input validation to ensure mutual exclusivity with existing repository-scoped functionality.
Key changes include:
- Added
enterprise
input parameter with validation for mutual exclusivity withowner
andrepositories
- Implemented enterprise installation discovery by listing all installations and filtering for enterprise type
- Added comprehensive test coverage for success scenarios, error cases, and input validation
Reviewed Changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
action.yml | Added enterprise input definition |
main.js | Added enterprise parameter reading and passing |
lib/main.js | Core logic for enterprise token generation and validation |
package.json | Version bump to 2.0.7 |
README.md | Documentation for enterprise usage |
tests/*.js | Comprehensive test suite for enterprise functionality |
tests/snapshots/index.js.md | Test output snapshots for verification |
Comments suppressed due to low confidence (1)
// Find the enterprise installation | ||
const enterpriseInstallation = response.data.find( | ||
installation => installation.target_type === "Enterprise" && | ||
installation.account?.slug === enterprise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison uses installation.account?.slug
but the test snapshots show installation.account.login
being used. Based on the test data structure, this should be installation.account?.login === enterprise
to match the enterprise name correctly.
installation.account?.slug === enterprise | |
installation.account?.login === enterprise |
Copilot uses AI. Check for mistakes.
`Inputs 'owner' and 'repositories' are not set. Creating token for this repository (${owner}/${repo}).` | ||
); | ||
} | ||
skipTokenRevoke, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The trailing comma followed by an empty line and then the closing parenthesis creates inconsistent formatting. Either move the closing parenthesis to the same line or remove the empty line.
Copilot uses AI. Check for mistakes.
This pull request introduces support for generating GitHub App tokens for enterprise-level installations. It includes updates to the main logic, input validation, and new tests to ensure functionality and edge case handling.
Code Changes
action.yml
: Addedenterprise
input with proper description and validation hints.main.js
: Added enterprise input reading and parameter passing.lib/main.js
:getTokenFromEnterprise
function following existing patterns but with difference on how we get the installation. Currently we do not have a way to get the installation for an enterprise directly, so the implementation lists all installations and filter for the enterprise one to take the id. This works fine for now as the Enterprise GitHub Apps cannot be installed on multiple enterprises but something to potentially change when we get dedicated API.package.json
: bumped the version.Documentation
README.md
to include instructions for using the newenterprise
input.Tests
tests/
directory to verify the behavior of theenterprise
input:owner
andrepositories
.Refs: