From 709b8aff661f3e9de8e3831380834b37ff065549 Mon Sep 17 00:00:00 2001 From: Nindi Gill Date: Tue, 13 Aug 2024 10:59:23 +1000 Subject: [PATCH 1/3] Perform Fleet server version lookup just-in-time --- .github/gitops-action/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/gitops-action/action.yml b/.github/gitops-action/action.yml index 17f26da..f2860fc 100644 --- a/.github/gitops-action/action.yml +++ b/.github/gitops-action/action.yml @@ -18,7 +18,9 @@ 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" --silent | jq --raw-output '.version')" + npm install -g fleetctl@$FLEET_VERSION - name: Configure fleetctl shell: bash From 85a11291cedbb564a24f6af8665432108b4e6af8 Mon Sep 17 00:00:00 2001 From: Nindi Gill Date: Tue, 13 Aug 2024 23:19:31 +1000 Subject: [PATCH 2/3] Add --fail flag to curl command --- .github/gitops-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/gitops-action/action.yml b/.github/gitops-action/action.yml index f2860fc..fb7743d 100644 --- a/.github/gitops-action/action.yml +++ b/.github/gitops-action/action.yml @@ -19,8 +19,8 @@ runs: shell: bash working-directory: ${{ inputs.working-directory }} run: | - FLEET_VERSION="$(curl "$FLEET_URL/api/v1/fleet/version" --header "Authorization: Bearer $FLEET_API_TOKEN" --silent | jq --raw-output '.version')" npm install -g fleetctl@$FLEET_VERSION + FLEET_VERSION="$(curl "$FLEET_URL/api/v1/fleet/version" --header "Authorization: Bearer $FLEET_API_TOKEN" --fail --silent | jq --raw-output '.version')" - name: Configure fleetctl shell: bash From ea847678400a01b2bb406f7c5cba4b03f07dbead Mon Sep 17 00:00:00 2001 From: Nindi Gill Date: Tue, 13 Aug 2024 23:20:19 +1000 Subject: [PATCH 3/3] Conditionally install latest / specific version of fleetctl --- .github/gitops-action/action.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/gitops-action/action.yml b/.github/gitops-action/action.yml index fb7743d..27ee3ff 100644 --- a/.github/gitops-action/action.yml +++ b/.github/gitops-action/action.yml @@ -19,9 +19,15 @@ runs: shell: bash working-directory: ${{ inputs.working-directory }} run: | - npm install -g fleetctl@$FLEET_VERSION 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 working-directory: ${{ inputs.working-directory }}