Skip to content

Commit

Permalink
Add post action cleanup to remove kind cluster (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayboras committed Aug 8, 2020
1 parent eadddd1 commit cd1c4c7
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ jobs:
run: |
kubectl cluster-info
kubectl get storageclass standard
test-with-custom-name:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Create kind cluster with custom name
uses: ./
with:
cluster_name: "custom-name"

- name: Test
run: |
kubectl cluster-info
kubectl get storageclass standard
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ inputs:
runs:
using: "node12"
main: "main.js"
post: "cleanup.js"
19 changes: 19 additions & 0 deletions cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright The Helm Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// # You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// # See the License for the specific language governing permissions and
// limitations under the License.

const spawnSync = require('child_process').spawnSync;
const path = require("path");

const proc = spawnSync('bash', [path.join(__dirname, 'cleanup.sh')], {stdio: 'inherit'});
process.exit(proc.status)
36 changes: 36 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# Copyright The Helm Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

DEFAULT_CLUSTER_NAME=chart-testing

main() {
args=()

if [[ -n "${INPUT_CLUSTER_NAME:-}" ]]; then
args+=(--name "${INPUT_CLUSTER_NAME}")
else
args+=(--name "${DEFAULT_CLUSTER_NAME}")
fi

kind delete cluster "${args[@]}"
}

main

0 comments on commit cd1c4c7

Please sign in to comment.