Files
flux2/action/action.yml
Kingdon Barrett 369ae5aa71 Quote tested values in fluxcd/flux GitHub Action
Fix an issue with improperly quoted variables created by #3474

Also, curl should fail with an error code if the download results in
404 not found

* + (x3) Update action/action.yml
* for consistent format

Co-authored-by: Steven E. Harris <seh@panix.com>
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2023-01-23 14:51:18 -05:00

61 lines
1.9 KiB
YAML

name: Setup Flux CLI
description: A GitHub Action for running Flux commands
author: Stefan Prodan
branding:
color: blue
icon: command
inputs:
version:
description: "Flux version e.g. 0.8.0 (defaults to latest stable release)"
required: false
arch:
description: "arch can be amd64, arm64 or arm"
required: true
default: "amd64"
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:
- name: "Download flux binary to tmp"
shell: bash
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 "${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"
curl --silent --fail --location "${BIN_URL}" --output /tmp/flux.tar.gz
mkdir -p /tmp/flux
tar -C /tmp/flux/ -zxvf /tmp/flux.tar.gz
- name: "Copy Flux binary to execute location"
shell: bash
run: |
BINDIR=${{ inputs.bindir }}
if [ -z "${BINDIR}" ]; then
sudo cp /tmp/flux/flux /usr/local/bin
else
cp /tmp/flux/flux "${BINDIR}"
echo "${BINDIR}" >> $GITHUB_PATH
fi
- name: "Cleanup tmp"
shell: bash
run: |
rm -rf /tmp/flux/ /tmp/flux.tar.gz
- name: "Verify correct installation of binary"
shell: bash
run: |
flux -v