commit d61836080a5f5c92069339ecb46939ce9cd8c2ba Author: jonas Date: Thu Mar 13 07:51:48 2025 +0000 Add .gitea/workflows/k3s.yaml diff --git a/.gitea/workflows/k3s.yaml b/.gitea/workflows/k3s.yaml new file mode 100644 index 0000000..e1f92f9 --- /dev/null +++ b/.gitea/workflows/k3s.yaml @@ -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 \ No newline at end of file