feat: add ability to auth to github api

Signed-off-by: Erik Kristensen <erik@erikkristensen.com>
pull/3474/head
Erik Kristensen 2 years ago
parent e59889297c
commit 1d82629b34

@ -15,6 +15,9 @@ inputs:
bindir: bindir:
description: "Optional location of the Flux binary. Will not use sudo if set. Updates System Path." description: "Optional location of the Flux binary. Will not use sudo if set. Updates System Path."
required: false required: false
token:
description: "GitHub Token used to authentication against the API (generally only needed to prevent quota limit errors)"
required: false
runs: runs:
using: composite using: composite
steps: steps:
@ -23,9 +26,14 @@ runs:
run: | run: |
ARCH=${{ inputs.arch }} ARCH=${{ inputs.arch }}
VERSION=${{ inputs.version }} VERSION=${{ inputs.version }}
TOKEN=${{ inputs.token }}
if [ -n $TOKEN ]; then
TOKEN=(-H "Authorization: token $TOKEN")
fi
if [ -z $VERSION ]; then if [ -z $VERSION ]; then
VERSION=$(curl https://api.github.com/repos/fluxcd/flux2/releases/latest -sL | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-) VERSION=$(curl https://api.github.com/repos/fluxcd/flux2/releases/latest -sL "${TOKEN[@]}" | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
fi fi
BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz" BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz"

Loading…
Cancel
Save