Skip to content

Adds GITHUB_BASE_URL input #503

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
dev-env-vars
.coverage*
__pycache__
.idea/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ jobs:
with:
GITHUB_TOKEN: ${{ github.token }}

# Change this in case you use GitHub Entreprise with a different API endpoint
GITHUB_BASE_URL: https://api.github.com

# Only necessary in the "workflow_run" workflow.
GITHUB_PR_RUN_ID: ${{ inputs.GITHUB_PR_RUN_ID }}

Expand Down Expand Up @@ -594,6 +597,10 @@ source =
This action is supposedly compatible with private repository. Just make sure
to use the svg badge directly, and not the `shields.io` URL.

## Github Enterprise (GHE) Support

This action should be compatible with GitHub Enterprise. Just make sure to set the `GITHUB_BASE_URL` input to your GHE URL.

## Upgrading from v2 to v3

When upgrading, we change the location and format where the coverage
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ description: >
Publish diff coverage report as PR comment, and create a coverage badge
to display on the readme.
inputs:
GITHUB_BASE_URL:
description: >
The base URL for the GitHub API, typically used to specify custom endpoints
for GitHub Enterprise Server (e.g., `https://github.mycompany.com/api/v3`).
Defaults to `https://api.github.com` for GitHub.com.
default: "https://api.github.com"
required: false
GITHUB_TOKEN:
description: >
A GitHub token to write comments and write the badge & coverage data
Expand Down
2 changes: 1 addition & 1 deletion coverage_comment/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def main():
config = settings.Config.from_environ(environ=os.environ)

github_session = httpx.Client(
base_url="https://api.github.com",
base_url=config.GITHUB_BASE_URL,
follow_redirects=True,
headers={"Authorization": f"token {config.GITHUB_TOKEN}"},
)
Expand Down
1 change: 1 addition & 0 deletions coverage_comment/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Config:

# A branch name, not a fully-formed ref. For example, `main`.
GITHUB_BASE_REF: str
GITHUB_BASE_URL: str = "https://api.github.com"
GITHUB_TOKEN: str = dataclasses.field(repr=False)
GITHUB_REPOSITORY: str
# > The ref given is fully-formed, meaning that for branches the format is
Expand Down
Loading