Skip to content

feat: add support for enterprise-level GitHub Apps#263

Merged
parkerbxyz merged 42 commits intoactions:mainfrom
theztefan:main
May 8, 2026
Merged

feat: add support for enterprise-level GitHub Apps#263
parkerbxyz merged 42 commits intoactions:mainfrom
theztefan:main

Conversation

@theztefan
Copy link
Copy Markdown
Contributor

@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 input to action.yml.
  • Wired enterprise through main.js and lib/main.js.
  • Added validation so enterprise 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.
  • Updated dist/main.cjs for the bundled action.
  • Shared token creation retry behavior across repository, owner, and enterprise paths so server errors and transient network errors are retried, while client errors fail immediately.

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
  • owner installation client errors are not retried
  • transient network errors are retried during token creation

Notes

  • This keeps the existing repository-scoped token behavior unchanged.
  • Owner, repository, and enterprise token creation now share the same retry policy: server errors and recognized transient network errors are retried, while client errors fail immediately. This intentionally fixes the previous owner-path behavior that retried client errors.

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
Copy Markdown
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)

Comment thread lib/main.js Outdated
Comment thread lib/main.js Outdated
Comment thread README.md
Comment thread README.md Outdated
Comment thread action.yml
Comment thread lib/main.js
Comment thread lib/main.js
Comment thread lib/main.js
Comment thread lib/main.js Outdated
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

arturcic commented Feb 9, 2026

@hpsin any updates?

@hpsin
Copy link
Copy Markdown

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
Copy Markdown

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
parkerbxyz and others added 4 commits April 30, 2026 12:30
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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.

Copilot's findings

  • Files reviewed: 13/15 changed files
  • Comments generated: 2

Comment thread tests/main-enterprise-mutual-exclusivity-owner.test.js Outdated
Comment thread tests/main-enterprise-mutual-exclusivity-repositories.test.js Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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.

Copilot's findings

  • Files reviewed: 13/15 changed files
  • Comments generated: 1

Comment thread action.yml
parkerbxyz and others added 3 commits May 8, 2026 00:25
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The generic permissions test already covers forwarding permission inputs into installation token creation. Remove the enterprise-specific case because the only currently generated enterprise permission does not match the documented installable-organizations API example.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep coverage for the enterprise token path forwarding permission inputs into installation token creation. Use a generated enterprise permission input instead of the undeclared enterprise-organizations and enterprise-people inputs from the original test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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.

Copilot's findings

  • Files reviewed: 13/15 changed files
  • Comments generated: 1

Comment thread lib/main.js Outdated
Make repository retry failure logs self-contained by formatting repository targets as owner/repo instead of only repo names.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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.

Copilot's findings

  • Files reviewed: 13/15 changed files
  • Comments generated: 2

Comment thread lib/main.js Outdated
Comment thread lib/main.js
Retry recognized network errors in addition to HTTP 5xx responses when creating installation tokens, while preserving immediate failure for 4xx client errors. Also clarify the enterprise installation 404 message with the quoted enterprise slug.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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.

Copilot's findings

  • Files reviewed: 15/18 changed files
  • Comments generated: 0 new

@parkerbxyz parkerbxyz merged commit 952a2a7 into actions:main May 8, 2026
8 checks passed
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