From db01e51404237262b9f9d4313556dbe412e813c2 Mon Sep 17 00:00:00 2001 From: thethreemagi Date: Thu, 14 May 2026 20:40:01 +0100 Subject: [PATCH] Add git-pull-exec entrypoint --- entrypoints/git-pull-exec.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 entrypoints/git-pull-exec.sh diff --git a/entrypoints/git-pull-exec.sh b/entrypoints/git-pull-exec.sh new file mode 100644 index 0000000..638390e --- /dev/null +++ b/entrypoints/git-pull-exec.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Entrypoint: pull latest code from Gitea before exec. +# Env vars: +# GIT_BRANCH (default: main) +# GIT_SSH_KEY (default: /secrets/gitea_deploy_key) +# +# YAML/config changes in the repo are live on next container start +# or ofelia exec — no rebuild needed. + +set -e + +BRANCH="${GIT_BRANCH:-main}" +SSH_KEY="${GIT_SSH_KEY:-/secrets/gitea_deploy_key}" + +if [ -f "$SSH_KEY" ]; then + export GIT_SSH_COMMAND="ssh -i $SSH_KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/.known_hosts" +fi + +if [ -d "/app/.git" ]; then + echo "[entrypoint] Pulling latest ($BRANCH)..." + git -C /app fetch origin + git -C /app reset --hard "origin/$BRANCH" + echo "[entrypoint] Done." +fi + +exec "$@"