Skip to content

Commit

Permalink
Add GHES support (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: dom <[email protected]>
Co-authored-by: Javier Ferrer <[email protected]>
  • Loading branch information
3 people committed Mar 3, 2021
1 parent 417e60a commit d56e9ca
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ jobs:
l_max_size: '450'
fail_if_xl: 'true'
message_if_xl: 'This PR is sooooo big!! 😳'
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ jobs:

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

### Github Enterprise Server

You can override the public Github API by setting `github_api_url`.

```yml
- uses: codelytv/pr-size-labeler@v1
with:
...
github_api_url: 'github.mycompany.net/api/v3'
```

## ⚖️ License

[MIT](LICENSE)
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: 'Message to show if the PR is xl size'
required: false
default: ''
github_api_url:
description: 'URI to the API of your Github Server, necessary for Github Enterprise customers'
required: false
default: 'api.github.com'
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -39,6 +43,7 @@ runs:
- ${{ inputs.l_max_size }}
- ${{ inputs.fail_if_xl }}
- ${{ inputs.message_if_xl }}
- ${{ inputs.github_api_url }}
branding:
icon: 'tag'
color: 'green'
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
set -euo pipefail

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

if [ "$PR_SIZE_LABELER_HOME" == "/" ]; then
PR_SIZE_LABELER_HOME=""
fi

if [ ! -z "$8" ]; then
PR_SIZE_LABELER_API=$8
fi

export PR_SIZE_LABELER_HOME
export PR_SIZE_LABELER_API

bash --version

Expand Down
2 changes: 1 addition & 1 deletion src/github.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

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

github::calculate_total_modifications() {
Expand Down
2 changes: 1 addition & 1 deletion src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source "$PR_SIZE_LABELER_HOME/src/misc.sh"
main() {
ensure::env_variable_exist "GITHUB_REPOSITORY"
ensure::env_variable_exist "GITHUB_EVENT_PATH"
ensure::total_args 7 "$@"
ensure::total_args 8 "$@"

export GITHUB_TOKEN="$1"

Expand Down

0 comments on commit d56e9ca

Please sign in to comment.