From 1d82629b34ec165772dd2762abcadcd4cec022cf Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 9 Jan 2023 08:24:45 -0700 Subject: [PATCH] feat: add ability to auth to github api Signed-off-by: Erik Kristensen --- action/action.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/action/action.yml b/action/action.yml index 7bb0be5c..f92686a9 100644 --- a/action/action.yml +++ b/action/action.yml @@ -15,6 +15,9 @@ inputs: bindir: description: "Optional location of the Flux binary. Will not use sudo if set. Updates System Path." required: false + token: + description: "GitHub Token used to authentication against the API (generally only needed to prevent quota limit errors)" + required: false runs: using: composite steps: @@ -23,9 +26,14 @@ runs: run: | ARCH=${{ inputs.arch }} VERSION=${{ inputs.version }} + TOKEN=${{ inputs.token }} + + if [ -n $TOKEN ]; then + TOKEN=(-H "Authorization: token $TOKEN") + fi 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 BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz"