docs: add local scheduled maintenance runner (no auto-push)
This commit is contained in:
@@ -57,6 +57,11 @@ bash scripts/docs/docs_backup.sh --dry-run
|
|||||||
bash scripts/docs/docs_backup.sh --apply
|
bash scripts/docs/docs_backup.sh --apply
|
||||||
```
|
```
|
||||||
|
|
||||||
|
7. Local scheduler (daily, no auto-push):
|
||||||
|
```bash
|
||||||
|
bash scripts/docs/install_local_cron.sh --schedule "17 9 * * *"
|
||||||
|
```
|
||||||
|
|
||||||
## Runtime-First Facts (must re-check each session)
|
## Runtime-First Facts (must re-check each session)
|
||||||
|
|
||||||
1. NODE1 branch/SHA:
|
1. NODE1 branch/SHA:
|
||||||
|
|||||||
@@ -60,6 +60,34 @@ cd /Users/apple/github-projects/microdao-daarion
|
|||||||
bash scripts/docs/docs_sync.sh --apply --targets github,gitea
|
bash scripts/docs/docs_sync.sh --apply --targets github,gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 5) Local scheduled run (no auto-push)
|
||||||
|
|
||||||
|
Install/update daily cron job (local timezone):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/apple/github-projects/microdao-daarion
|
||||||
|
bash scripts/docs/install_local_cron.sh --schedule "17 9 * * *"
|
||||||
|
```
|
||||||
|
|
||||||
|
Dry-run preview:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/apple/github-projects/microdao-daarion
|
||||||
|
bash scripts/docs/install_local_cron.sh --dry-run
|
||||||
|
```
|
||||||
|
|
||||||
|
Uninstall:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/apple/github-projects/microdao-daarion
|
||||||
|
bash scripts/docs/install_local_cron.sh --uninstall
|
||||||
|
```
|
||||||
|
|
||||||
|
Runner command:
|
||||||
|
- `scripts/docs/run_docs_maintenance.sh`
|
||||||
|
- executes `services_sync --apply` and `docs_lint`
|
||||||
|
- does not perform any `git push`
|
||||||
|
|
||||||
## Safety gates
|
## Safety gates
|
||||||
|
|
||||||
- `docs_sync.sh` is dry-run by default.
|
- `docs_sync.sh` is dry-run by default.
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ doc_paths=(
|
|||||||
scripts/docs/session_bootstrap.sh
|
scripts/docs/session_bootstrap.sh
|
||||||
scripts/docs/docs_backup.sh
|
scripts/docs/docs_backup.sh
|
||||||
scripts/docs/docs_lint.sh
|
scripts/docs/docs_lint.sh
|
||||||
|
scripts/docs/run_docs_maintenance.sh
|
||||||
|
scripts/docs/install_local_cron.sh
|
||||||
scripts/docs/jupyter_sync.sh
|
scripts/docs/jupyter_sync.sh
|
||||||
scripts/docs/pieces_sync.sh
|
scripts/docs/pieces_sync.sh
|
||||||
scripts/docs/services_sync.sh
|
scripts/docs/services_sync.sh
|
||||||
|
|||||||
86
scripts/docs/install_local_cron.sh
Executable file
86
scripts/docs/install_local_cron.sh
Executable file
@@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
SCHEDULE="${DOCS_CRON_SCHEDULE:-17 9 * * *}"
|
||||||
|
DRY_RUN=0
|
||||||
|
UNINSTALL=0
|
||||||
|
MARK_START="# >>> microdao docs maintenance >>>"
|
||||||
|
MARK_END="# <<< microdao docs maintenance <<<"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'USAGE'
|
||||||
|
Usage:
|
||||||
|
bash scripts/docs/install_local_cron.sh [--schedule "17 9 * * *"] [--dry-run] [--uninstall]
|
||||||
|
|
||||||
|
Default schedule:
|
||||||
|
17 9 * * * (local timezone)
|
||||||
|
|
||||||
|
Installs a single managed cron block that runs:
|
||||||
|
bash scripts/docs/run_docs_maintenance.sh
|
||||||
|
|
||||||
|
No git push is performed by maintenance script.
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--schedule)
|
||||||
|
SCHEDULE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--dry-run)
|
||||||
|
DRY_RUN=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--uninstall)
|
||||||
|
UNINSTALL=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown arg: $1" >&2
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! command -v crontab >/dev/null 2>&1; then
|
||||||
|
echo "crontab command not found" >&2
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
current="$(crontab -l 2>/dev/null || true)"
|
||||||
|
cleaned="$(printf '%s\n' "$current" | awk -v s="$MARK_START" -v e="$MARK_END" '
|
||||||
|
BEGIN{skip=0}
|
||||||
|
index($0,s)>0 {skip=1; next}
|
||||||
|
index($0,e)>0 {skip=0; next}
|
||||||
|
skip==0 {print}
|
||||||
|
')"
|
||||||
|
|
||||||
|
if [[ "$UNINSTALL" -eq 1 ]]; then
|
||||||
|
new_cron="$cleaned"
|
||||||
|
else
|
||||||
|
cmd="cd $ROOT_DIR && mkdir -p docs/consolidation/logs && bash scripts/docs/run_docs_maintenance.sh >> docs/consolidation/logs/cron_runner.log 2>&1"
|
||||||
|
block="$MARK_START\n$SCHEDULE $cmd\n$MARK_END"
|
||||||
|
if [[ -n "$cleaned" ]]; then
|
||||||
|
new_cron="$cleaned\n$block"
|
||||||
|
else
|
||||||
|
new_cron="$block"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||||
|
echo "[dry-run] resulting crontab:"
|
||||||
|
printf '%b\n' "$new_cron"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%b\n' "$new_cron" | crontab -
|
||||||
|
|
||||||
|
echo "crontab updated"
|
||||||
|
crontab -l
|
||||||
62
scripts/docs/run_docs_maintenance.sh
Executable file
62
scripts/docs/run_docs_maintenance.sh
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
LOG_DIR="$ROOT_DIR/docs/consolidation/logs"
|
||||||
|
STAMP="$(date +%Y%m%d-%H%M%S)"
|
||||||
|
LOG_FILE="$LOG_DIR/docs_maintenance_${STAMP}.log"
|
||||||
|
LATEST_LOG="$LOG_DIR/docs_maintenance_latest.log"
|
||||||
|
DRY_RUN=0
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'USAGE'
|
||||||
|
Usage:
|
||||||
|
bash scripts/docs/run_docs_maintenance.sh [--dry-run]
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
1) services sync (--apply or --dry-run)
|
||||||
|
2) docs lint
|
||||||
|
|
||||||
|
No git push is performed.
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--dry-run)
|
||||||
|
DRY_RUN=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown arg: $1" >&2
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p "$LOG_DIR"
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "[docs-maintenance] started: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
|
||||||
|
echo "[docs-maintenance] repo: $ROOT_DIR"
|
||||||
|
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||||
|
echo "[docs-maintenance] mode: dry-run"
|
||||||
|
bash "$ROOT_DIR/scripts/docs/services_sync.sh" --dry-run
|
||||||
|
else
|
||||||
|
echo "[docs-maintenance] mode: apply"
|
||||||
|
bash "$ROOT_DIR/scripts/docs/services_sync.sh" --apply
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[docs-maintenance] lint start"
|
||||||
|
bash "$ROOT_DIR/scripts/docs/docs_lint.sh"
|
||||||
|
echo "[docs-maintenance] success"
|
||||||
|
} > "$LOG_FILE" 2>&1
|
||||||
|
|
||||||
|
cp "$LOG_FILE" "$LATEST_LOG"
|
||||||
|
echo "Wrote: $LOG_FILE"
|
||||||
|
echo "Updated: $LATEST_LOG"
|
||||||
Reference in New Issue
Block a user