Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Oct 7, 2023
1 parent 8b39279 commit f0fc814
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ jobs:
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: Create kwok cluster
# uses: ./actions/create-cluster # kubernetes-sigs/kwok/actions/create-cluster@main
- name: Install kwokctl
uses: ./actions/kwok # kubernetes-sigs/kwok/actions/kwok@main
with:
command: kwokctl
- name: Test kwokctl
shell: bash
run: kubectl version
run: |
kwokctl create cluster --name kwok --wait 120s
kubectl version
2 changes: 1 addition & 1 deletion actions/create-cluster/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
uses: ./actions/kwok
with:
command: kwokctl
args: create cluster --name ${{ inputs.cluster-name }}
args: create cluster --name ${{ inputs.cluster-name }} --wait 120s
kwok-version: ${{ inputs.kwok-version }}
env:
KWOK_KUBE_VERSION: ${{ inputs.kube-version }}
34 changes: 22 additions & 12 deletions actions/kwok/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: This action runs kwok

inputs:
args:
required: true
required: false
description: Arguments passed to `kwok` or `kwokctl`
kwok-version:
required: false
Expand All @@ -23,17 +23,27 @@ runs:
KWOK_REPO: ${{ github.repository }}
KWOK_VERSION: ${{ inputs.kwok-version }}
run: |
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')"
fi
if [[ ! -f ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} ]]; then
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')"
fi
echo "Installing ${{ inputs.command }} ${KWOK_VERSION}..."
mkdir -p ~/.kwok/bin/
curl -o ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)"
chmod +x ~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION}
curl -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
echo "Running ${{ inputs.command }} ${{ inputs.args }}"
~/.kwok/bin/${{ inputs.command }}-${KWOK_VERSION} ${{ inputs.args }}
if [[ -n "${{ inputs.args }}" ]]; then
echo "Running ${{ inputs.command }} ${{ inputs.args }}"
if ! ${{ inputs.command }} ${{ inputs.args }}; then
echo "Failed to run ${{ inputs.command }} ${{ inputs.args }}"
exit 1
fi
echo "Done!"
fi

0 comments on commit f0fc814

Please sign in to comment.