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:
@@ -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. |
|
| `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. |
|
| `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. |
|
| `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
@@ -26,6 +26,10 @@ inputs:
|
|||||||
description: 'Error out when we have an invalid resource. Default: false'
|
description: 'Error out when we have an invalid resource. Default: false'
|
||||||
required: false
|
required: false
|
||||||
default: '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:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
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
|
# 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.
|
# per GitHub account.
|
||||||
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
|
# 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 \
|
RELEASE_INFO="$(curl --silent --show-error --fail \
|
||||||
--header 'authorization: Bearer ${{ github.token }}' \
|
--header "$AUTH_HEADER" \
|
||||||
--header 'Cache-Control: no-cache, must-revalidate' \
|
--header 'Cache-Control: no-cache, must-revalidate' \
|
||||||
"${RELEASE_URL}")"
|
"${RELEASE_URL}")"
|
||||||
RELEASE_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".name")"
|
RELEASE_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".name")"
|
||||||
@@ -69,11 +77,11 @@ runs:
|
|||||||
else
|
else
|
||||||
CONFIG="--config ${{ inputs.config }}"
|
CONFIG="--config ${{ inputs.config }}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${{ inputs.fail-on-invalid-resource }}" == "true" ]]; then
|
if [[ "${{ inputs.fail-on-invalid-resource }}" == "true" ]]; then
|
||||||
FLAG_ARGS="--fail-on-invalid-resource "
|
FLAG_ARGS="--fail-on-invalid-resource "
|
||||||
else
|
else
|
||||||
FLAG_ARGS=""
|
FLAG_ARGS=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./kube-linter $CONFIG lint "${{ inputs.directory }}" --format "${{ inputs.format }}" $FLAG_ARGS | tee "${{ inputs.output-file }}"
|
./kube-linter $CONFIG lint "${{ inputs.directory }}" --format "${{ inputs.format }}" $FLAG_ARGS | tee "${{ inputs.output-file }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user