Skip to content

Commit

Permalink
Merge pull request #823 from wzshiming/fix/gh-action
Browse files Browse the repository at this point in the history
Fix gh actions
  • Loading branch information
wzshiming authored Oct 25, 2023
2 parents f293931 + 856fa7c commit 1e44a10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
sparse-checkout: |
action.yaml
- name: Set up kwokctl
uses: . # kubernetes-sigs/kwok@main
uses: ./ # kubernetes-sigs/kwok@main
with:
command: kwokctl
- name: Test kwokctl
Expand Down
36 changes: 24 additions & 12 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,41 @@ inputs:
repository:
required: false
description: Repository is kwok's repository, will use release from this repository, defaults same as uses in this step
default: "kubernetes-sigs/kwok"

runs:
using: composite
steps:
- name: Install ${{ inputs.command }}
shell: bash
env:
KWOK_REPO: ${{ inputs.repository || github.repository }}
KWOK_REPO: ${{ inputs.repository }}
KWOK_VERSION: ${{ inputs.kwok-version }}
run: |
if [[ ! -f /usr/local/bin/${{ inputs.command }}-${KWOK_VERSION} ]]; then
if [[ -f /usr/local/bin/${{ inputs.command }} ]]; then
echo "Found ${{ inputs.command }} in /usr/local/bin, skipping installation"
exit 0
fi
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')"
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}"
echo "Failed to fetch latest version"
exit 1
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"
if [[ "${KWOK_VERSION}" == "null" ]]; then
echo "Failed to fetch latest version"
exit 1
fi
echo "Latest version is ${KWOK_VERSION}"
fi
echo "Installing ${{ inputs.command }} ${KWOK_VERSION}..."
wget -O ${{ inputs.command }} "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)"
chmod +x ${{ inputs.command }}
sudo mv ${{ inputs.command }} /usr/local/bin/
if ! ${{ inputs.command }} --version; then
echo "Failed to run ${{ inputs.command }} --version"
exit 1
fi

0 comments on commit 1e44a10

Please sign in to comment.