Skip to content

Commit d56e9ca

Browse files
mambaxdomJavierCane
authored
Add GHES support (#22)
Co-authored-by: dom <[email protected]> Co-authored-by: Javier Ferrer <[email protected]>
1 parent 417e60a commit d56e9ca

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

.github/workflows/labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ jobs:
1717
l_max_size: '450'
1818
fail_if_xl: 'true'
1919
message_if_xl: 'This PR is sooooo big!! 😳'
20+
github_api_url: 'api.github.com' # It would be ideal to test this out pointing to a GitHub Enterprise server, but there are no testing environments available

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ jobs:
4747

4848
> Setting `fail_if_xl` to `'true'` will make fail all pull requests bigger than `l_max_size`.
4949

50+
### Github Enterprise Server
51+
52+
You can override the public Github API by setting `github_api_url`.
53+
54+
```yml
55+
- uses: codelytv/pr-size-labeler@v1
56+
with:
57+
...
58+
github_api_url: 'github.mycompany.net/api/v3'
59+
```
60+
5061
## ⚖️ License
5162

5263
[MIT](LICENSE)

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: 'Message to show if the PR is xl size'
2929
required: false
3030
default: ''
31+
github_api_url:
32+
description: 'URI to the API of your Github Server, necessary for Github Enterprise customers'
33+
required: false
34+
default: 'api.github.com'
3135
runs:
3236
using: 'docker'
3337
image: 'Dockerfile'
@@ -39,6 +43,7 @@ runs:
3943
- ${{ inputs.l_max_size }}
4044
- ${{ inputs.fail_if_xl }}
4145
- ${{ inputs.message_if_xl }}
46+
- ${{ inputs.github_api_url }}
4247
branding:
4348
icon: 'tag'
4449
color: 'green'

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
set -euo pipefail
33

44
PR_SIZE_LABELER_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
5+
PR_SIZE_LABELER_API="api.github.com"
56

67
if [ "$PR_SIZE_LABELER_HOME" == "/" ]; then
78
PR_SIZE_LABELER_HOME=""
89
fi
910

11+
if [ ! -z "$8" ]; then
12+
PR_SIZE_LABELER_API=$8
13+
fi
14+
1015
export PR_SIZE_LABELER_HOME
16+
export PR_SIZE_LABELER_API
1117

1218
bash --version
1319

src/github.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
GITHUB_API_URI="https://api.github.com"
3+
GITHUB_API_URI="https://$PR_SIZE_LABELER_API"
44
GITHUB_API_HEADER="Accept: application/vnd.github.v3+json"
55

66
github::calculate_total_modifications() {

src/main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ source "$PR_SIZE_LABELER_HOME/src/misc.sh"
99
main() {
1010
ensure::env_variable_exist "GITHUB_REPOSITORY"
1111
ensure::env_variable_exist "GITHUB_EVENT_PATH"
12-
ensure::total_args 7 "$@"
12+
ensure::total_args 8 "$@"
1313

1414
export GITHUB_TOKEN="$1"
1515

0 commit comments

Comments
 (0)