Add nightly lodge HA config backup workflow (exports to dfritz/home-assistant lodge/)
backup-lodge-ha / backup (push) Successful in 9s
backup-lodge-ha / backup (push) Successful in 9s
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -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'
|
||||||
Reference in New Issue
Block a user