Skip to content

Add support for enterprise level GitHub Apps#263

Open
theztefan wants to merge 21 commits intoactions:mainfrom
theztefan:main
Open

Add support for enterprise level GitHub Apps#263
theztefan wants to merge 21 commits intoactions:mainfrom
theztefan:main

Conversation

@theztefan
Copy link

@theztefan theztefan commented Jul 8, 2025

This pull request adds support for generating GitHub App installation tokens for enterprise-level installations.

What changed

  • Added a new enterprise-slug input to action.yml.
  • Wired enterprise-slug through main.js and lib/main.js.
  • Added validation so enterprise-slug cannot be combined with owner or repositories.
  • Implemented enterprise installation lookup using the direct GitHub API route GET /enterprises/{enterprise}/installation, then used the returned installation ID to mint an installation token through @octokit/auth-app.
  • Updated README.md with enterprise-installation usage and input documentation.

Tests

Added focused test coverage for:

  • enterprise token creation
  • enterprise token creation with explicit permissions
  • enterprise installation not found
  • mutual exclusivity with owner
  • mutual exclusivity with repositories

The test suite was also trimmed to remove redundant enterprise scenarios.

Notes

  • This keeps the existing action behavior unchanged for repository and owner-based installation tokens.
  • dist/ changes are intentionally not included in this PR.

Refs:

Copilot AI review requested due to automatic review settings July 8, 2025 15:24
@theztefan theztefan requested a review from a team as a code owner July 8, 2025 15:24

This comment was marked as outdated.

@parkerbxyz parkerbxyz requested a review from Copilot July 11, 2025 19:07
Copy link
Contributor

Copilot AI left a 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 with owner and repositories
  • 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)

lib/main.js Outdated
Comment on lines +212 to +220
// Get all installations and find the enterprise one
// https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app
// Note: Currently we do not have a way to get the installation for an enterprise directly,
// so as a workaround we need to list all installations and filter for the enterprise one.
const response = await request("GET /app/installations", {
request: {
hook: auth.hook,
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we do not have a way to get the installation for an enterprise directly, so as a workaround we need to list all installations and filter for the enterprise one.

Unfortunately, we will probably need to wait until there is a way to get the installation for an enterprise directly. Otherwise, we'll need to add pagination support for this to be reliable. This could be done via Octokit, but we've tried to keep dependencies to a minimum and would prefer to keep it that way.

theztefan and others added 8 commits August 28, 2025 09:33
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
@hpsin
Copy link

hpsin commented Nov 10, 2025

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.

@parkerbxyz
Copy link
Contributor

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 parkerbxyz linked an issue Nov 22, 2025 that may be closed by this pull request
@jdesulme
Copy link

Is there any update on using this experimental injection of the installation ID? At the very least, it would allow us to use it in the meantime, and we can switch over once a proper API is available. Since the installation ID won't change often for most users, hardcoding it wouldn't be a major issue.

@hpsin
Copy link

hpsin commented Dec 29, 2025

Hey all,
I have a PR open to add the required api, I'm hoping to ship it this week or next. I'll let you know when I do.

@arturcic
Copy link

arturcic commented Feb 9, 2026

@hpsin any updates?

@hpsin
Copy link

hpsin commented Feb 9, 2026

It should get announced today, and should be live on the API docs now - https://docs.github.com/en/enterprise-cloud@latest/rest/apps/apps?apiVersion=2022-11-28#get-an-enterprise-installation-for-the-authenticated-app

@arturcic
Copy link

@hpsin any chance to get this one merged/released?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
parkerbxyz and others added 8 commits March 13, 2026 16:03
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Apps requring enterprise-level access

6 participants