From 11021138d714d0953e5a2bbe22705d730dc27425 Mon Sep 17 00:00:00 2001 From: juvdiaz Date: Wed, 27 May 2026 14:35:17 -0600 Subject: [PATCH] Make Actions deploy checkout fallback explicit --- .gitea/workflows/homelab-main.yml | 18 +++++++++++++----- README.md | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/homelab-main.yml b/.gitea/workflows/homelab-main.yml index 3a88260..463eb57 100644 --- a/.gitea/workflows/homelab-main.yml +++ b/.gitea/workflows/homelab-main.yml @@ -123,16 +123,24 @@ jobs: run: | set -euo pipefail - deploy_dir="${HOMELAB_DEPLOY_DIR:-/home/jv/my-homelab-configs}" - test -d "${deploy_dir}/.git" - gitea_ssh_url="${GITEA_SSH_URL:-ssh://git@192.168.100.89:32222/jv/my-homelab-configs.git}" gitea_ssh_command="${GITEA_SSH_COMMAND:-ssh -i /home/jv/.ssh/id_ed25519 -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new}" + deploy_dir="${HOMELAB_DEPLOY_DIR:-/home/jv/my-homelab-configs}" + + if [[ ! -d "${deploy_dir}/.git" ]]; then + echo "Persistent deploy checkout ${deploy_dir} was not found; using Actions workspace ${PWD}." + deploy_dir="${PWD}" + fi + if [[ ! -d "${deploy_dir}/.git" ]]; then + echo "Deploy checkout ${deploy_dir} is not a Git repository." >&2 + exit 1 + fi + echo "Deploy checkout: ${deploy_dir}" + git -C "${deploy_dir}" remote set-url gitea "${gitea_ssh_url}" || \ git -C "${deploy_dir}" remote add gitea "${gitea_ssh_url}" GIT_SSH_COMMAND="${gitea_ssh_command}" git -C "${deploy_dir}" fetch gitea main - git -C "${deploy_dir}" checkout main - git -C "${deploy_dir}" reset --hard "${{ gitea.sha }}" + git -C "${deploy_dir}" checkout -B main "${{ gitea.sha }}" git -C "${deploy_dir}" remote set-url local-bootstrap /home/jv/git-server/my-homelab-configs.git || \ git -C "${deploy_dir}" remote add local-bootstrap /home/jv/git-server/my-homelab-configs.git git -C "${deploy_dir}" push local-bootstrap HEAD:main diff --git a/README.md b/README.md index f063436..4ae9aad 100644 --- a/README.md +++ b/README.md @@ -432,7 +432,8 @@ to `ssh://git@192.168.100.89:32222/jv/my-homelab-configs.git`. The default key is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH access unchanged. The Actions deploy job fetches the persistent Debian checkout -through that SSH endpoint. +through that SSH endpoint when `HOMELAB_DEPLOY_DIR` exists, and otherwise falls +back to the checked-out Actions workspace. Enable Actions for the repository in Gitea, then create a repository-level runner token from: