create-github-app-token
create-github-app-token copied to clipboard
Add support for enterprise level GitHub Apps
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: Addedenterpriseinput with proper description and validation hints.main.js: Added enterprise input reading and parameter passing.lib/main.js:- Added enterprise parameter to function signature.
- Added input validation for mutual exclusivity.
- Added enterprise branch in the token generation logic.
- Added
getTokenFromEnterprisefunction 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
- Updated
README.mdto include instructions for using the newenterpriseinput.
Tests
- Added multiple tests in the
tests/directory to verify the behavior of theenterpriseinput:- Tests for mutual exclusivity with
ownerandrepositories. - Tests for successful token generation with and without permissions.
- Test for handling scenarios where no enterprise installation is found.
- Tests for mutual exclusivity with
- All existing functionality remains unchanged. The enterprise feature is additive and does not affect existing users, so all previous tests pass as well.
Refs:
- https://github.blog/changelog/2025-07-01-enterprise-level-access-for-github-apps-and-installation-automation-apis/
- https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/organization-installations?apiVersion=2022-11-28
Thanks for this! I'm opening an issue to add the required API for this, since it is a clear gap. No ETA on the resolution I'm afraid.
Something we might be able to do while we await a dedicated API:
- Add a new
experimental-enterprise-installation-idinput, so the installation ID can be passed directly to this action. - Remove the
enterpriseinput (for now).
This should allow people to use this action with enterprise-level GitHub Apps.