Skip to content

Commit

Permalink
action: re-allow configuration of non-default token
Browse files Browse the repository at this point in the history
To allow usage of action on GitHub Enterprise instances.

Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Jul 10, 2023
1 parent 3311bfd commit fff44b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@ inputs:
description: "Alternative location for the Flux binary, defaults to path relative to $RUNNER_TOOL_CACHE."
required: false
token:
description: "GitHub Token used to authentication against the API (generally only needed to prevent quota limit errors)"
description: "GitHub Token used to authentication against the API. Defaults to the token from the GitHub context for the workflow."
required: false
deprecationMessage: "No longer required, action will now use GitHub token from runner."
runs:
using: composite
steps:
- name: "Download the binary to the runner's cache dir"
shell: bash
run: |
VERSION=${{ inputs.version }}
TOKEN=${{ inputs.token }}
if [[ -z "$TOKEN" ]]; then
TOKEN=${{ github.token }}
fi
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
if [[ -z "$VERSION" ]]; then
echo "Unable to determine Flux CLI version"
Expand Down

0 comments on commit fff44b5

Please sign in to comment.