Files
oaktracker/scripts/unraid-git-update.sh
T
FaroeGames 18c492488c
Build and Publish Docker Image / test-and-publish (push) Failing after 2m25s
Add Gitea Actions registry publish workflow and Unraid auto-update script
2026-11-17 15:29:45 -07:00

23 lines
711 B
Bash

#!/bin/bash
set -euo pipefail
# Schedule this in Unraid's "User Scripts" plugin (e.g. every 15 minutes)
# to automatically pull & rebuild whenever you push updates to Gitea.
APP_DIR="/mnt/user/appdata/professor-oak-tracker"
BRANCH="main"
cd "${APP_DIR}"
git fetch origin "${BRANCH}" --quiet
LOCAL_SHA="$(git rev-parse HEAD)"
REMOTE_SHA="$(git rev-parse "origin/${BRANCH}")"
if [ "${LOCAL_SHA}" != "${REMOTE_SHA}" ]; then
echo "[oaktracker] Update detected (${LOCAL_SHA:0:7} -> ${REMOTE_SHA:0:7}), rebuilding container..."
git pull --ff-only origin "${BRANCH}"
docker compose up -d --build
docker image prune -f >/dev/null 2>&1 || true
echo "[oaktracker] Updated cleanly to ${REMOTE_SHA:0:7}."
fi