1
0
mirror of https://github.com/stackrox/kube-linter-action.git synced 2026-07-04 23:51:37 +00:00

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
+1
View File
@@ -36,3 +36,4 @@ The workflow will fail if kube-linter detects issues. You'll find issues in the
| `output-file` | (optional) | Path to a file where kube-linter output will be stored. Default is `kube-linter.log`. File will be overwritten if it exists. |
| `version` | (optional) | kube-linter release version to use, e.g. "0.2.4". The latest available version is used by default. |
| `fail-on-invalid-resource` | (optional) | Set `true` to error out when we have an invalid resource. |
| `token` | (optional) | Token to use when pulling release info from github.com |
+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 }}"