Skip to content

Commit e0b4e2e

Browse files
committed
fix: skip kubectl download if already exists + detect OS and architecture in netlify-build.sh
1 parent c1c93a6 commit e0b4e2e

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

website/netlify-build.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,29 @@ set -e
44

55
source ./hack/lib/kubectl-version.sh
66

7-
wget -q https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl
8-
chmod +x ./kubectl
9-
10-
mkdir -p ~/bin
11-
mv ./kubectl ~/bin
7+
# Check if kubectl already exists in ~/bin
8+
if [ ! -f ~/bin/kubectl ]; then
9+
echo "Downloading kubectl..."
10+
11+
# Detect OS and architecture
12+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
13+
ARCH=$(uname -m)
14+
15+
# Map architecture names
16+
if [ "$ARCH" = "x86_64" ]; then
17+
ARCH="amd64"
18+
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
19+
ARCH="arm64"
20+
fi
21+
22+
wget -q https://dl.k8s.io/release/$KUBECTL_VERSION/bin/$OS/$ARCH/kubectl
23+
chmod +x ./kubectl
24+
25+
mkdir -p ~/bin
26+
mv ./kubectl ~/bin
27+
else
28+
echo "kubectl already exists in ~/bin, skipping download"
29+
fi
1230

1331
export PATH="$PATH:$HOME/bin"
1432

0 commit comments

Comments
 (0)