-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
140 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,7 @@ All input names in **bold** are _required_. | |
| `unprotect_reviews` | Momentarily remove pull request review protection from target branch.<br>**Note**: One needs administrative access to the repository to be able to use this feature. This means two things need to match up: The PAT must represent a user with administrative rights, and these rights need to be granted to the usage scope of the PAT. | `False` | | ||
| `debug` | Set `set -x` in `entrypoint.sh` when running the action. This is for debugging the action. | `False` | | ||
| `path` | A path to the working directory of the action. This should be relative to the `$GITHUB_WORKSPACE`. | `.` | | ||
| `gh_rest_api_base_url` | The base URL for the GitHub REST API. This is useful for GitHub Enterprise users.</br>Note, `/api/v3` will be appended to this value if it does not already exist. See the note [here](https://docs.github.com/en/[email protected]/rest/quickstart?apiVersion=2022-11-28&tool=curl#using-curl-commands-in-github-actions). | `https://api.github.com` | | ||
|
||
## License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,10 @@ inputs: | |
description: 'A path to the working directory of the action. This should be relative to the $GITHUB_WORKSPACE.' | ||
required: false | ||
default: '.' | ||
gh_rest_api_base_url: | ||
description: 'The base URL for the GitHub REST API. This is useful for GitHub Enterprise users. Note, `/api/v3` will be appended to this value if it does not already exist. See the note here: https://docs.github.com/en/[email protected]/rest/quickstart?apiVersion=2022-11-28&tool=curl#using-curl-commands-in-github-actions.' | ||
required: false | ||
default: 'https://api.github.com' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Validate inputs.""" | ||
from urllib.parse import urlsplit | ||
|
||
GITHUB_FREE_REST_API_BASE_URL = "https://api.github.com" | ||
"""Base URL for GitHub Free API.""" | ||
|
||
GITHUB_ENTERPRISE_API_PREFIX = "/api/v3" | ||
"""Prefix for GitHub Enterprise API URLs. | ||
See the note for more information here: | ||
https://docs.github.com/en/[email protected]/rest/quickstart?apiVersion=2022-11-28&tool=curl#using-curl-commands-in-github-actions. | ||
""" | ||
|
||
|
||
def validate_rest_api_base_url(base_url: str) -> str: | ||
"""Validate and parse the `gh_rest_api_base_url` input.""" | ||
split_base_url = urlsplit(base_url) | ||
|
||
if not split_base_url.scheme or not split_base_url.netloc: | ||
raise ValueError( | ||
"Invalid URL provided for `gh_rest_api_base_url` input (missing scheme " | ||
"and/or netloc)." | ||
) | ||
|
||
compiled_url = split_base_url.scheme + "://" + split_base_url.netloc | ||
|
||
if compiled_url == GITHUB_FREE_REST_API_BASE_URL: | ||
return compiled_url | ||
|
||
url_path = split_base_url.path.rstrip("/") | ||
|
||
if url_path and not split_base_url.path.endswith(GITHUB_ENTERPRISE_API_PREFIX): | ||
raise ValueError( | ||
"Invalid URL provided for `gh_rest_api_base_url` input (path must end with " | ||
f"{GITHUB_ENTERPRISE_API_PREFIX!r})." | ||
) | ||
|
||
if not url_path: | ||
compiled_url += GITHUB_ENTERPRISE_API_PREFIX | ||
|
||
return compiled_url |