From 0333046891906bc255c688e155211aeb696bebfe Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 5 Jul 2026 19:40:45 +0000 Subject: [PATCH] Add nightly lodge HA config backup workflow (exports to dfritz/home-assistant lodge/) Co-Authored-By: Claude Fable 5 --- .gitea/workflows/backup-ha.yaml | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .gitea/workflows/backup-ha.yaml diff --git a/.gitea/workflows/backup-ha.yaml b/.gitea/workflows/backup-ha.yaml new file mode 100644 index 0000000..f36e158 --- /dev/null +++ b/.gitea/workflows/backup-ha.yaml @@ -0,0 +1,50 @@ +name: backup-lodge-ha +# Nightly export of the lodge HA config (scripts/automations/dashboards/helpers) +# into dfritz/home-assistant lodge/. Secrets: HA_TOKEN (lodge HA long-lived +# token), GIT_TOKEN (ops PAT with write:repository). Lives in this repo because +# ops has admin here; move to dfritz/home-assistant if its owner adds the +# HA_TOKEN secret there. +on: + schedule: + - cron: '37 9 * * *' # 04:37 America/Chicago during CDT (03:37 CST) + workflow_dispatch: {} + push: + branches: [main] + paths: ['.gitea/workflows/backup-ha.yaml'] + +jobs: + backup: + runs-on: fritzlab + timeout-minutes: 15 + steps: + - name: clone mirror repo + run: git clone "https://ops:${{ secrets.GIT_TOKEN }}@code.fritzlab.net/dfritz/home-assistant.git" mirror + + - name: install python deps + run: pip install --break-system-packages --quiet websockets pyyaml + + - name: export lodge HA config + working-directory: mirror + env: + HA_TOKEN: ${{ secrets.HA_TOKEN }} + run: | + rm -rf lodge/scripts lodge/automations lodge/dashboards + python3 lodge/export.py + + - name: commit and push if changed + working-directory: mirror + run: | + git config user.name "lodge-ha-backup" + git config user.email "ops@fritzlab.net" + git add lodge/ + if git diff --cached --quiet; then echo "no changes"; exit 0; fi + git commit -m "lodge: automated HA config export" + git push + + - name: notify on failure + if: failure() + uses: https://code.fritzlab.net/action/notify-email@v1 + with: + status: failure + summary: "Lodge HA config backup failed" + auto-log: 'true'