support setting token for github enterprise (#31)

Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
This commit is contained in:
Nelo-T. Wallus
2025-05-05 17:42:08 +02:00
committed by GitHub
parent c232ba1364
commit 87802a2f4e
2 changed files with 12 additions and 3 deletions
+11 -3
View File
@@ -26,6 +26,10 @@ inputs:
description: 'Error out when we have an invalid resource. Default: false'
required: false
default: 'false'
token:
description: 'Used to pull release info from GitHub. Does not need to be supplied on github.com.'
required: false
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
runs:
using: "composite"
steps:
@@ -46,8 +50,12 @@ runs:
# in order to increase the limit of 60 requests per hour per IP address to a higher value that's also counted
# per GitHub account.
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
AUTH_HEADER=""
if [[ "${{ inputs.token }}" != "" ]]; then
AUTH_HEADER="Authorization: Bearer ${{ inputs.token }}"
fi
RELEASE_INFO="$(curl --silent --show-error --fail \
--header 'authorization: Bearer ${{ github.token }}' \
--header "$AUTH_HEADER" \
--header 'Cache-Control: no-cache, must-revalidate' \
"${RELEASE_URL}")"
RELEASE_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".name")"
@@ -69,11 +77,11 @@ runs:
else
CONFIG="--config ${{ inputs.config }}"
fi
if [[ "${{ inputs.fail-on-invalid-resource }}" == "true" ]]; then
FLAG_ARGS="--fail-on-invalid-resource "
else
FLAG_ARGS=""
fi
./kube-linter $CONFIG lint "${{ inputs.directory }}" --format "${{ inputs.format }}" $FLAG_ARGS | tee "${{ inputs.output-file }}"