name: k8s smoke test

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  test:
    runs-on: self-hosted
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Write kubeconfig from secret
        env:
          KUBECONFIG_CONTENT: ${{ secrets.KUBECONFIG }}
        run: |
          mkdir -p /tmp/kube
          printf '%s\n' "$KUBECONFIG_CONTENT" > /tmp/kube/config

      - name: Test kubectl connectivity
        env:
          KUBECONFIG: /tmp/kube/config
        run: |
          kubectl get nodes --kubeconfig "${KUBECONFIG}"
