Skip to content

Commit 293b8e5

Browse files
authored
Merge pull request #20 from nolar/skip-cluster-creation
Add an option to skip the cluster creation
2 parents 181c711 + e947bd7 commit 293b8e5

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.github/workflows/ci.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ jobs:
4848
K3S: ${{ steps.install.outputs.k3s-version }}
4949
K8S: ${{ steps.install.outputs.k8s-version }}
5050

51+
test-skip-creation:
52+
name: Skip creation
53+
runs-on: ubuntu-22.04
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: ./ # normally: nolar/setup-k3d-k3s@v1
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
59+
skip-creation: true
60+
5161
test-skip-readiness:
5262
name: Skip readiness
5363
runs-on: ubuntu-22.04

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ with:
105105
```
106106

107107

108+
### `skip-creation`
109+
110+
Whether to return from the action as soon as possible
111+
without the cluster creation (the cluster readiness is also skipped).
112+
This can be useful to only install the tools for manual cluster creation,
113+
or to parse the available versions and return them as the action's outputs.
114+
115+
By default (`false`), the cluster is created.
116+
117+
108118
### `skip-readiness`
109119

110120
Whether to return from the action as soon as possible,

action.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ echo "k3s-version=${K3S}" >> $GITHUB_OUTPUT
7777
echo "k8s-version=${K8S}" >> $GITHUB_OUTPUT
7878

7979
# Start a cluster. It takes 20 seconds usually.
80-
k3d cluster create ${K3D_NAME:-} --wait --image=rancher/k3s:"${K3S//+/-}" ${K3D_ARGS:-}
80+
if [[ -z "${SKIP_CREATION}" ]]; then
81+
k3d cluster create ${K3D_NAME:-} --wait --image=rancher/k3s:"${K3S//+/-}" ${K3D_ARGS:-}
82+
else
83+
echo "Skipping the cluster creation. The cluster can be not fully ready yet."
84+
fi
8185

8286
# Sometimes, the service account is not created immediately. Nice trick, but no:
8387
# we need to wait until the cluster is fully ready before starting the tests.
84-
if [[ -z "${SKIP_READINESS}" ]]; then
88+
if [[ -z "${SKIP_CREATION}" && -z "${SKIP_READINESS}" ]]; then
8589
echo "::group::Waiting for cluster readiness"
8690
while ! kubectl get serviceaccount default >/dev/null; do sleep 1; done
8791
echo "::endgroup::"

action.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ inputs:
2222
github-token:
2323
description: Optional GitHub token to overcome API rate limiting.
2424
required: false
25+
skip-creation:
26+
description: Skip creating the cluster and waiting for its readiness?
27+
required: false
2528
skip-readiness:
2629
description: Skip waiting for full cluster readiness?
2730
required: false
@@ -47,8 +50,10 @@ runs:
4750
K3D_NAME: ${{ inputs.k3d-name }}
4851
K3D_ARGS: ${{ inputs.k3d-args }}
4952
GITHUB_TOKEN: ${{ inputs.github-token }}
53+
SKIP_CREATION: ${{ inputs.skip-creation && 'yes' || '' }}
5054
SKIP_READINESS: ${{ inputs.skip-readiness && 'yes' || '' }}
5155

5256
# Validate that everything is installed, is on PATH, and generally works.
5357
- shell: bash
5458
run: kubectl version
59+
if: ${{ !inputs.skip-creation }}

0 commit comments

Comments
 (0)