Skip to content

Commit

Permalink
Report K3d version as an output
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
  • Loading branch information
nolar committed Oct 5, 2021
1 parent e102477 commit d50e310
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ resources to appear (e.g., for a service account named "default").

## Outputs

### `k3d-version`

The specific K3d version that was detected and used. E.g. `v5.0.0`.


### `k3s-version`

The specific K3s version that was detected and used. E.g. `v1.21.2+k3s1`.
Expand Down
15 changes: 11 additions & 4 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ fi
K3S=$(jq --slurp <<< "$versions_matching" --raw-output '.[0]')
K8S=${K3S%%+*}

# Communicate back to GitHub Actions.
echo "::set-output name=k3s-version::${K3S}"
echo "::set-output name=k8s-version::${K8S}"

# Install K3d and start a K3s cluster. It takes 20 seconds usually.
# Name & args can be empty or multi-value. For this, they are not quoted.
if [[ "${K3D_TAG:-}" == "latest" ]]; then
Expand All @@ -70,6 +66,17 @@ fi
curl --silent --fail https://raw.githubusercontent.com/rancher/k3d/main/install.sh \
| TAG=${K3D_TAG:-} bash
k3d --version
K3D=$(k3d --version | grep -Po 'k3d version \K(v[\S]+)' || true )

# Communicate back to GitHub Actions.
echo "Detected k3d-version::${K3D}"
echo "Detected k3s-version::${K3S}"
echo "Detected k8s-version::${K8S}"
echo "::set-output name=k3d-version::${K3D}"
echo "::set-output name=k3s-version::${K3S}"
echo "::set-output name=k8s-version::${K8S}"

# Start a cluster. It takes 20 seconds usually.
k3d cluster create ${K3D_NAME:-} --wait --image=rancher/k3s:"${K3S//+/-}" ${K3D_ARGS:-}

# Sometimes, the service account is not created immediately. Nice trick, but no:
Expand Down
3 changes: 3 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ inputs:
description: Skip waiting for full cluster readiness?
required: false
outputs:
k3d-version:
description: Actual version of K3d detected and used.
value: ${{ steps.main.outputs.k3d-version }}
k3s-version:
description: Actual version of K3s detected and used.
value: ${{ steps.main.outputs.k3s-version }}
Expand Down

0 comments on commit d50e310

Please sign in to comment.