Add .gitea/workflows/k3s.yaml
Some checks failed
k3s / build (push) Failing after 12s

This commit is contained in:
jonas 2025-03-13 07:51:48 +00:00
commit d61836080a

51
.gitea/workflows/k3s.yaml Normal file
View File

@ -0,0 +1,51 @@
name: k3s
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install kubectl
env:
KUBE_CONFIG: ${{ secrets.KUBE_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