From ffe861bea4f8c83e69e72d15c9b9e4b5a3c59d68 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:47:24 +0800 Subject: [PATCH 1/9] Update action.yaml --- action.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index b59e0a3..1213f25 100644 --- a/action.yaml +++ b/action.yaml @@ -33,9 +33,12 @@ inputs: runs: using: composite steps: - - id: main - shell: bash - run: ${{ github.action_path }}/run.sh deploy + - uses: pyTooling/Actions/with-post-step@v0.4.6 + with: + main: | + ${{ github.action_path }}/run.sh deploy + post: | + ${{ github.action_path }}/run.sh teardown env: CLUSTER_NAME: ${{ inputs.cluster-name }} ARGS: ${{ inputs.args }} From 73cc0bbd7a1707572ce9aaf2ba660845d367c881 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:52:58 +0800 Subject: [PATCH 2/9] Update action.yaml --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 1213f25..76c9fec 100644 --- a/action.yaml +++ b/action.yaml @@ -33,7 +33,7 @@ inputs: runs: using: composite steps: - - uses: pyTooling/Actions/with-post-step@v0.4.6 + - uses: gacts/run-and-post-run@v1 with: main: | ${{ github.action_path }}/run.sh deploy From bd92cb288dcb395e489c0b5fe78a9dcec983d494 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:57:08 +0800 Subject: [PATCH 3/9] Update run.sh --- run.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/run.sh b/run.sh index 8d9f230..65fbf77 100755 --- a/run.sh +++ b/run.sh @@ -72,6 +72,17 @@ deploy(){ wait_for_nodes } +teardown(){ + local name=${CLUSTER_NAME} + + if [[ -z "${CLUSTER_NAME}" ]]; then + panic "CLUSTER_NAME must be set" + fi + + echo -e "\existing_network${YELLOW}Teardown cluster ${CYAN}$name ${NC}" + eval "k3d cluster delete $name +} + # waits until all nodes are ready wait_for_nodes(){ echo -e "${YELLOW}wait until all agents are ready${NC}" @@ -121,6 +132,9 @@ case "$1" in "deploy") deploy ;; + "teardown") + teardown + ;; # "") # command_handler # ;; From 81f4c0a765918197089480926bdfc9181bf1ac3b Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:58:59 +0800 Subject: [PATCH 4/9] Update run.sh --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 65fbf77..9e301b5 100755 --- a/run.sh +++ b/run.sh @@ -80,7 +80,7 @@ teardown(){ fi echo -e "\existing_network${YELLOW}Teardown cluster ${CYAN}$name ${NC}" - eval "k3d cluster delete $name + eval "k3d cluster delete $name" } # waits until all nodes are ready From c47a9017e5eed389689340c1acf2379fbad03e78 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:01:16 +0800 Subject: [PATCH 5/9] Update action.yaml --- action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yaml b/action.yaml index 76c9fec..8fc6373 100644 --- a/action.yaml +++ b/action.yaml @@ -36,8 +36,14 @@ runs: - uses: gacts/run-and-post-run@v1 with: main: | + export CLUSTER_NAME="${{ inputs.cluster-name }}" + export ARGS="${{ inputs.args }}" + export K3D_VERSION="${{ inputs.k3d-version }}" ${{ github.action_path }}/run.sh deploy post: | + export CLUSTER_NAME="${{ inputs.cluster-name }}" + export ARGS="${{ inputs.args }}" + export K3D_VERSION="${{ inputs.k3d-version }}" ${{ github.action_path }}/run.sh teardown env: CLUSTER_NAME: ${{ inputs.cluster-name }} From 1d2015894cb5d40356f7f8527abc373db6ad7198 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:02:24 +0800 Subject: [PATCH 6/9] Update action.yaml --- action.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/action.yaml b/action.yaml index 8fc6373..76c9fec 100644 --- a/action.yaml +++ b/action.yaml @@ -36,14 +36,8 @@ runs: - uses: gacts/run-and-post-run@v1 with: main: | - export CLUSTER_NAME="${{ inputs.cluster-name }}" - export ARGS="${{ inputs.args }}" - export K3D_VERSION="${{ inputs.k3d-version }}" ${{ github.action_path }}/run.sh deploy post: | - export CLUSTER_NAME="${{ inputs.cluster-name }}" - export ARGS="${{ inputs.args }}" - export K3D_VERSION="${{ inputs.k3d-version }}" ${{ github.action_path }}/run.sh teardown env: CLUSTER_NAME: ${{ inputs.cluster-name }} From 031b06b7f90eae15250b8478c343312131e6f0de Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:03:18 +0800 Subject: [PATCH 7/9] Update run.sh --- run.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 9e301b5..afcca2e 100755 --- a/run.sh +++ b/run.sh @@ -74,11 +74,16 @@ deploy(){ teardown(){ local name=${CLUSTER_NAME} - + local arguments=${ARGS:-} + local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}} + if [[ -z "${CLUSTER_NAME}" ]]; then panic "CLUSTER_NAME must be set" fi + echo -e "${YELLOW}Downloading ${CYAN}k3d@${k3dVersion} ${NC}see: ${K3D_URL}" + curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash + echo -e "\existing_network${YELLOW}Teardown cluster ${CYAN}$name ${NC}" eval "k3d cluster delete $name" } From 7e18408180c8f363f4da98b77bc0dda89b55e992 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:05:12 +0800 Subject: [PATCH 8/9] Update action.yaml --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 76c9fec..bcb919d 100644 --- a/action.yaml +++ b/action.yaml @@ -35,7 +35,7 @@ runs: steps: - uses: gacts/run-and-post-run@v1 with: - main: | + run: | ${{ github.action_path }}/run.sh deploy post: | ${{ github.action_path }}/run.sh teardown From e068df705164d76e46eb444985398f9063f00580 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:38:14 +0800 Subject: [PATCH 9/9] Update run.sh --- run.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/run.sh b/run.sh index afcca2e..93ee6c7 100755 --- a/run.sh +++ b/run.sh @@ -38,6 +38,7 @@ usage(){ Usage: $(basename "$0") Commands: deploy deploy custom k3d cluster + teardown teardown custom k3d cluster Environment variables: deploy @@ -46,6 +47,8 @@ usage(){ ARGS (Optional) k3d arguments. K3D_VERSION (Optional) k3d version. + teardown + CLUSTER_NAME (Required) k3d cluster name. EOF } @@ -74,16 +77,11 @@ deploy(){ teardown(){ local name=${CLUSTER_NAME} - local arguments=${ARGS:-} - local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}} - + if [[ -z "${CLUSTER_NAME}" ]]; then panic "CLUSTER_NAME must be set" fi - echo -e "${YELLOW}Downloading ${CYAN}k3d@${k3dVersion} ${NC}see: ${K3D_URL}" - curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash - echo -e "\existing_network${YELLOW}Teardown cluster ${CYAN}$name ${NC}" eval "k3d cluster delete $name" }