k3s-template/.gitea/workflows/k3s.yaml
jonas fa17a5399f
Some checks failed
CI / build (push) Failing after 20s
Update .gitea/workflows/k3s.yaml
2025-03-13 08:32:13 +00:00

53 lines
1.5 KiB
YAML

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install kubectl
env:
KUBE_CONFIG: ${{ secrets.K3S_CONFIG }}
shell: bash
run: |
# Fetch the latest stable version of kubectl
KUBECTL_VERSION=$(curl -s https://dl.k8s.io/release/stable.txt)
if [ -z "$KUBECTL_VERSION" ]; then
echo "Failed to fetch the latest kubectl version. Exiting."
exit 1
fi
# Download kubectl binary
curl -LO "https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl"
if [ $? -ne 0 ]; then
echo "Failed to download kubectl binary. Exiting."
exit 1
fi
# Make kubectl executable and move to PATH
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
# Verify kubectl installation
kubectl version --client
# Install kubelogin
curl -fsSLO https://github.com/int128/kubelogin/releases/download/v1.25.4/kubelogin_linux_amd64.zip
unzip kubelogin_linux_amd64.zip kubelogin -d kubelogin
mv kubelogin/kubelogin kubelogin/kubectl-oidc_login
export PATH=$PATH:$(realpath kubelogin)
# Configure kubeconfig
mkdir -p ~/.kube
echo "$KUBE_CONFIG" > ~/.kube/config
kubectl delete -f kubernetes.yaml
kubectl apply -f kubernetes.yaml