create-github-app-token icon indicating copy to clipboard operation
create-github-app-token copied to clipboard

Add support for enterprise level GitHub Apps

Open theztefan opened this issue 5 months ago • 1 comments

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: Added enterprise input 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 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

  • Updated README.md to include instructions for using the new enterprise input.

Tests

  • Added multiple tests in the tests/ directory to verify the behavior of the enterprise input:
    • Tests for mutual exclusivity with owner and repositories.
    • Tests for successful token generation with and without permissions.
    • Test for handling scenarios where no enterprise installation is found.
  • 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

theztefan avatar Jul 08 '25 15:07 theztefan

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.

hpsin avatar Nov 10 '25 18:11 hpsin

Something we might be able to do while we await a dedicated API:

  • Add a new experimental-enterprise-installation-id input, so the installation ID can be passed directly to this action.
  • Remove the enterprise input (for now).

This should allow people to use this action with enterprise-level GitHub Apps.

parkerbxyz avatar Nov 21 '25 20:11 parkerbxyz