Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement teardown action #51

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ inputs:
runs:
using: composite
steps:
- id: main
shell: bash
run: ${{ github.action_path }}/run.sh deploy
- uses: gacts/run-and-post-run@v1
with:
run: |
${{ github.action_path }}/run.sh deploy
post: |
${{ github.action_path }}/run.sh teardown
Comment on lines +36 to +41
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that this would be an unnecessary way to run teardown over and over again in VM-based workflows. Could it be done differently?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think you shouldn't assume it will be VM based since you can run act locally -- given you just have Docker access, and act pretty much replicates 60% of GHA to let you run it locally so that you can test the workflow before it goes live on master.

env:
CLUSTER_NAME: ${{ inputs.cluster-name }}
ARGS: ${{ inputs.args }}
Expand Down
17 changes: 17 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ usage(){
Usage: $(basename "$0") <COMMAND>
Commands:
deploy deploy custom k3d cluster
teardown teardown custom k3d cluster

Environment variables:
deploy
Expand All @@ -46,6 +47,8 @@ usage(){
ARGS (Optional) k3d arguments.

K3D_VERSION (Optional) k3d version.
teardown
CLUSTER_NAME (Required) k3d cluster name.
EOF
}

Expand All @@ -72,6 +75,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}"
Expand Down Expand Up @@ -121,6 +135,9 @@ case "$1" in
"deploy")
deploy
;;
"teardown")
teardown
;;
# "<put new command here>")
# command_handler
# ;;
Expand Down