action: re-allow configuration of non-default token

To allow usage of action on GitHub Enterprise instances.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
pull/4061/head
Hidde Beydals 2 years ago
parent 3311bfd3ca
commit 6fa495b843
No known key found for this signature in database
GPG Key ID: 979F380FC2341744

@ -16,9 +16,8 @@ inputs:
description: "Alternative location for the Flux binary, defaults to path relative to $RUNNER_TOOL_CACHE." description: "Alternative location for the Flux binary, defaults to path relative to $RUNNER_TOOL_CACHE."
required: false required: false
token: token:
description: "GitHub Token used to authentication against the API (generally only needed to prevent quota limit errors)" description: "Token used to authentication against the GitHub.com API. Defaults to the token from the GitHub context of the workflow."
required: false required: false
deprecationMessage: "No longer required, action will now use GitHub token from runner."
runs: runs:
using: composite using: composite
steps: steps:
@ -26,8 +25,14 @@ runs:
shell: bash shell: bash
run: | run: |
VERSION=${{ inputs.version }} VERSION=${{ inputs.version }}
TOKEN=${{ inputs.token }}
if [[ -z "$TOKEN" ]]; then
TOKEN=${{ github.token }}
fi
if [[ -z "$VERSION" ]] || [[ "$VERSION" = "latest" ]]; then if [[ -z "$VERSION" ]] || [[ "$VERSION" = "latest" ]]; then
VERSION=$(curl -fsSL -H "Authorization: token ${{ github.token }}" https://api.github.com/repos/fluxcd/flux2/releases/latest | grep tag_name | cut -d '"' -f 4) VERSION=$(curl -fsSL -H "Authorization: token ${TOKEN}" https://api.github.com/repos/fluxcd/flux2/releases/latest | grep tag_name | cut -d '"' -f 4)
fi fi
if [[ -z "$VERSION" ]]; then if [[ -z "$VERSION" ]]; then
echo "Unable to determine Flux CLI version" echo "Unable to determine Flux CLI version"

Loading…
Cancel
Save