Skip to content

Commit

Permalink
Add Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Oct 7, 2023
1 parent 7f6881a commit b1b1d33
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test Actions

on:
pull_request:
push:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create kwok cluster
uses: ./actions/create-cluster # kubernetes-sigs/kwok/actions/create-cluster@main
- name: Test kwokctl
shell: bash
run: kubectl --version
27 changes: 27 additions & 0 deletions actions/create-cluster/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Create kwok cluster

description: This action creates a kwok cluster

inputs:
kube-version:
required: false
description: Kubernetes version to use
cluster-name:
required: false
description: Name of the cluster to create
default: kwok
kwok-version:
required: false
description: KWOK version to use

runs:
using: composite
steps:
- name: Create kwok cluster
uses: ./actions/kwok
with:
command: kwokctl
args: create cluster --name ${{ inputs.cluster-name }}
kwok-version: ${{ inputs.kwok-version }}
env:
KWOK_KUBE_VERSION: ${{ inputs.kube-version }}
39 changes: 39 additions & 0 deletions actions/kwok/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: kwok

description: This action runs kwok

inputs:
args:
required: true
description: Arguments passed to `kwok` or `kwokctl`
kwok-version:
required: false
description: KWOK version to use
command:
required: false
description: Command to run
default: kwok

runs:
using: composite
steps:
- name: Install and start kwok
shell: bash
env:
KWOK_REPO: ${{ github.repository }}
KWOK_VERSION: ${{ inputs.kwok-version }}
run: |
if [[ -z "${KWOK_VERSION}" ]]; then
KWOK_VERSION="$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name')"
fi
BIN_PATH="~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION}"
if [[ -x "${BIN_PATH}" ]]; then
${BIN_PATH} ${{ inputs.args }}
exit 0
fi
mkdir -p ~/.kwok/bin
wget -O "${BIN_PATH}" -c "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)"
chmod +x "${BIN_PATH}"
${BIN_PATH} ${{ inputs.args }}

0 comments on commit b1b1d33

Please sign in to comment.