From 698bce2fe65fd5407b1daed6f3779265a20ce245 Mon Sep 17 00:00:00 2001 From: Nindi Gill Date: Tue, 13 Aug 2024 23:40:16 +1000 Subject: [PATCH] Match Fleet server version with fleetctl version (#45) * Perform Fleet server version lookup just-in-time * Add --fail flag to curl command * Conditionally install latest / specific version of fleetctl --- .github/gitops-action/action.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/gitops-action/action.yml b/.github/gitops-action/action.yml index 17f26da..27ee3ff 100644 --- a/.github/gitops-action/action.yml +++ b/.github/gitops-action/action.yml @@ -18,7 +18,15 @@ runs: - name: Install fleetctl shell: bash working-directory: ${{ inputs.working-directory }} - run: npm install -g fleetctl + run: | + FLEET_VERSION="$(curl "$FLEET_URL/api/v1/fleet/version" --header "Authorization: Bearer $FLEET_API_TOKEN" --fail --silent | jq --raw-output '.version')" + + if [[ -n "$FLEET_VERSION" ]] ; then + npm install -g "fleetctl@$FLEET_VERSION" + else + echo "Failed to get Fleet version from $FLEET_URL, installing latest version of fleetctl" + npm install -g fleetctl + fi - name: Configure fleetctl shell: bash