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 12, 2023
1 parent 0813f31 commit 0e23bf3
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test Setup GitHub Actions

on:
pull_request:
paths:
- action.yaml
- .github/workflows/test-action.yaml

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
action.yaml
- name: Set up kwokctl
uses: . # kubernetes-sigs/kwok@main
with:
command: kwokctl
- name: Test kwokctl
shell: bash
run: |
kwokctl --version
kwokctl create cluster
kubectl version
kwokctl delete cluster
40 changes: 40 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup kwok

description: This action sets up kwok/kwokctl for use in your workflow

inputs:
command:
required: true
description: Command to install
kwok-version:
required: false
description: Specific version of command to install, defaults to latest release
repository:
required: false
description: Repository is kwok's repository, will use release from this repository, defaults same as uses in this step

runs:
using: composite
steps:
- name: Install ${{ inputs.command }}
shell: bash
env:
KWOK_REPO: ${{ inputs.repository || github.repository }}
KWOK_VERSION: ${{ inputs.kwok-version }}
run: |
if [[ ! -f /usr/local/bin/${{ inputs.command }}-${KWOK_VERSION} ]]; then
if [[ -z "${KWOK_VERSION}" ]]; then
echo "Fetching latest version..."
KWOK_VERSION="$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name')"
echo "Latest version is ${KWOK_VERSION}"
fi
echo "Installing ${{ inputs.command }} ${KWOK_VERSION}..."
wget -O ${{ inputs.command }}-${KWOK_VERSION} "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)"
chmod +x ${{ inputs.command }}-${KWOK_VERSION}
sudo mv ${{ inputs.command }}-${KWOK_VERSION} /usr/local/bin/
sudo ln -sf /usr/local/bin/${{ inputs.command }}-${KWOK_VERSION} /usr/local/bin/${{ inputs.command }}
if ! ${{ inputs.command }} --version; then
echo "Failed to run ${{ inputs.command }} --version"
exit 1
fi
fi
4 changes: 4 additions & 0 deletions site/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ menu:
pageRef: "/docs/user/all-in-one-image"
weight: 1010
parent: user-guide
- identifier: github-action
pageRef: "/docs/user/github-action"
weight: 1015
parent: user-guide
- identifier: installation
pageRef: "/docs/user/installation"
weight: 1020
Expand Down
40 changes: 40 additions & 0 deletions site/content/en/docs/user/github-action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Github Action
---

# Github Action

{{< hint "info" >}}

This document walks through the steps to use in the Github Action.

{{< /hint >}}

## Usage

``` yaml
- uses: kubernetes-sigs/kwok@main
with:
# Required: The command to install ('kwok' or 'kwokctl')
command: ''
# Optional: Specific version of command to install, defaults to latest release
kwok-version: ''
```
### Create Cluster
``` yaml
- name: Set up kwokctl
uses: kubernetes-sigs/kwok@main
with:
command: kwokctl
- run: kwokctl create cluster
env:
KWOK_KUBE_VERSION: v1.28.0
```
## Next steps
Now, you can use `kwok` to [manage nodes and pods] in the Kubernetes cluster.

[manage nodes and pods]: {{< relref "/docs/user/kwok-manage-nodes-and-pods" >}}

0 comments on commit 0e23bf3

Please sign in to comment.