Skip to content
Merged
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
6 changes: 5 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: engineerd/setup-kind@v0.3.0
- name: "npm install"
run: npm install
- name: "npm run build"
run: npm run build
- uses: ./
- name: Testing
run: |
kubectl cluster-info
Expand Down
20 changes: 15 additions & 5 deletions src/kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const NameInput: string = "name";
const WaitInput: string = "wait";
const SkipClusterCreationInput: string = "skipClusterCreation";

const toolName: string = "kind";

export class KindConfig {
version: string
configFile: string;
Expand Down Expand Up @@ -69,16 +71,24 @@ export function getKindConfig(): KindConfig {
}

// this action should always be run from a Linux worker
export async function downloadKind(version: string) {
export async function downloadKind(version: string): Promise<string> {
let url: string = `https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-linux-amd64`;
console.log("downloading kind from " + url);
let downloadPath: string | null = null;
downloadPath = await tc.downloadTool(url);
const binPath: string = "/home/runner/bin";
await io.mkdirP(binPath);
await exec.exec("chmod", ["+x", downloadPath]);
await io.mv(downloadPath, path.join(binPath, "kind"));
let toolPath: string = await tc.cacheFile(downloadPath, "kind", toolName, version);
core.debug(`kind is cached under ${toolPath}`);

core.addPath(binPath);
return toolPath;
}

export async function getKind(version: string): Promise<string> {
let toolPath: string = tc.find(toolName, version);

if (toolPath === "") {
toolPath = await downloadKind(version);
}

return toolPath;
}
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as core from '@actions/core';
import { KindConfig, getKindConfig, downloadKind } from './kind';
import { KindConfig, getKindConfig, getKind } from './kind';

async function run() {
try {
let cfg: KindConfig = getKindConfig();
await downloadKind(cfg.version);
let toolPath: string = await getKind(cfg.version);
core.addPath(toolPath);
await cfg.createCluster();
} catch (error) {
core.setFailed(error.message);
Expand Down