From 80648f8e7a06470c1fd1bacfe4173a3b41e19bd4 Mon Sep 17 00:00:00 2001 From: juvdiaz Date: Wed, 27 May 2026 14:44:41 -0600 Subject: [PATCH] Run cluster rebuild when Actions has no kubeconfig --- .gitea/workflows/homelab-main.yml | 21 ++++++++++++++++++++- README.md | 11 ++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/homelab-main.yml b/.gitea/workflows/homelab-main.yml index 9b2e016..1197606 100644 --- a/.gitea/workflows/homelab-main.yml +++ b/.gitea/workflows/homelab-main.yml @@ -155,4 +155,23 @@ jobs: fi git -C "${deploy_dir}" push local-bootstrap HEAD:main - "${deploy_dir}/lab.sh" apps + kubeconfig_probe="${KUBECONFIG_PATH:-${TF_VAR_kubeconfig_path:-${HOME}/.kube/config}}" + action_command="${HOMELAB_ACTION_COMMAND:-auto}" + if [[ "${action_command}" == "auto" ]]; then + if [[ -s "${kubeconfig_probe}" ]]; then + action_command="apps" + else + action_command="rebuild-cluster" + fi + fi + + case "${action_command}" in + apps | rebuild-cluster) + echo "Running lab.sh ${action_command}" + "${deploy_dir}/lab.sh" "${action_command}" + ;; + *) + echo "Unsupported HOMELAB_ACTION_COMMAND: ${action_command}" >&2 + exit 1 + ;; + esac diff --git a/README.md b/README.md index abb7a4c..d9e50fc 100644 --- a/README.md +++ b/README.md @@ -370,8 +370,8 @@ The Debian bare repo remains the GitOps mirror: ``` Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running -`./lab.sh apps`. +Gitea Actions pushes the `main` commit into the mirror before running the +selected deploy command. Deploy or refresh the external Gitea container from the Debian host with: @@ -424,7 +424,12 @@ a repository-scoped Debian host runner with the label `homelab-debian`. The workflow only blocks automatic deploy for Raspberry Pi Gitea service changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, `install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `lab.sh`. Other changes proceed directly to `./lab.sh apps`. +functions in `lab.sh`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by +default: Actions runs `./lab.sh apps` when the Debian runner already has a +cluster kubeconfig, or `./lab.sh rebuild-cluster` when it does not. + +Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` +on the runner to force one path. `./lab.sh bootstrap-gitea-repo` also registers the Debian host SSH public key with the Gitea repository and switches the Debian working copy's `gitea` remote