fix(workflow): fjern push-trigger — kjør kun schedule (03:00 UTC) + workflow_dispatch

This commit is contained in:
chrischristiansen-glitch 2026-05-25 11:45:23 +02:00
parent 1cea31d50c
commit c733eea613

View File

@ -1,13 +1,12 @@
name: Nightly GDrive Backup
# Kjører kl 03:00 UTC (05:00 CEST) hver natt + ved push til main
# Kjører kl 03:00 UTC (05:00 CEST) hver natt
# Manuell kjøring: GitHub UI → Actions → Nightly GDrive Backup → Run workflow
# NB: push-trigger er bevisst fjernet — kjør kun schedule + manuelt
on:
schedule:
- cron: '0 3 * * *'
push:
branches:
- main
workflow_dispatch: # manuell trigger fra GitHub UI
workflow_dispatch:
jobs:
backup:
@ -19,17 +18,33 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # full historikk for git bundle
fetch-depth: 0
# ── 1. Installer rclone ───────────────────────────────────────────────
# ── 1. Installer rclone ─────────────────────────────────────────────────
- name: Install rclone
run: |
curl https://rclone.org/install.sh | sudo bash
rclone version
# ── 2. Konfigurer rclone med GDrive service account ───────────────────
# Forutsetter at RCLONE_GDRIVE_SA_JSON er lagt inn som GitHub Secret
# og at GDRIVE_BACKUP_FOLDER_ID peker på riktig GDrive-mappe
# ── 2. Valider at secrets er satt ───────────────────────────────────────
- name: Validate secrets
env:
SA_JSON: ${{ secrets.RCLONE_GDRIVE_SA_JSON }}
FOLDER_ID: ${{ secrets.GDRIVE_BACKUP_FOLDER_ID }}
run: |
if [[ -z "$SA_JSON" ]]; then
echo "❌ RCLONE_GDRIVE_SA_JSON er ikke satt som GitHub Secret."
echo " Se docs/GDRIVE_SETUP.md for instruksjoner."
exit 1
fi
if [[ -z "$FOLDER_ID" ]]; then
echo "❌ GDRIVE_BACKUP_FOLDER_ID er ikke satt som GitHub Secret."
echo " Se docs/GDRIVE_SETUP.md for instruksjoner."
exit 1
fi
echo "✔ Secrets OK"
# ── 3. Konfigurer rclone med GDrive service account ─────────────────
- name: Configure rclone
env:
RCLONE_GDRIVE_SA_JSON: ${{ secrets.RCLONE_GDRIVE_SA_JSON }}
@ -44,7 +59,7 @@ jobs:
root_folder_id = ${GDRIVE_FOLDER_ID}
EOF
# ── 3. Nøkkelfiler (MD-indeks) → GDrive/vauco-mirror/ ─────────────────
# ── 4. Nøkkelfiler (MD-indeks) → GDrive/vauco-mirror/ ───────────────
- name: Sync key docs to GDrive mirror folder
run: |
rclone copy docs/AGENT_RULEBOOK.md gdrive:vauco-mirror/
@ -53,10 +68,10 @@ jobs:
rclone copy docs/VAUCO_OS_ROADMAP.md gdrive:vauco-mirror/
rclone copy docs/TODO.md gdrive:vauco-mirror/
rclone copy MASTERPLAN.md gdrive:vauco-mirror/
rclone copy protocols/sessions/index.md gdrive:vauco-mirror/sessions/
rclone copy protocols/sessions/index.md gdrive:vauco-mirror/sessions/ || true
echo "[backup] Nøkkelfiler synkronisert → GDrive/vauco-mirror/"
# ── 4. Full repo-backup som git bundle → GDrive/vauco-backup/ ────────
# ── 5. Full repo-backup som git bundle → GDrive/vauco-backup/ ────────
- name: Create git bundle
run: |
TIMESTAMP=$(date '+%Y-%m-%dT%H%M')
@ -70,7 +85,7 @@ jobs:
rclone copy "/tmp/${{ env.BUNDLE_NAME }}" gdrive:vauco-backup/
echo "[backup] Bundle lastet opp → GDrive/vauco-backup/${{ env.BUNDLE_NAME }}"
# ── 5. Rydd gamle bundles (behold siste 7) ────────────────────────────
# ── 6. Rydd gamle bundles (behold siste 7) ───────────────────────
- name: Prune old bundles (keep last 7)
run: |
rclone ls gdrive:vauco-backup/ \
@ -80,7 +95,7 @@ jobs:
| xargs -I{} rclone deletefile gdrive:vauco-backup/{} || true
echo "[backup] Gamle bundles ryddet (behold 7 siste)"
# ── 6. Sammendrag ─────────────────────────────────────────────────────
# ── 7. Sammendrag ────────────────────────────────────────────────────────
- name: Summary
run: |
echo "=== BACKUP FERDIG ==="