Sync runbooks from git
Keep Veirox runbook entities in sync with a git repo. Any commit that changes a file under runbooks/ upserts the entity automatically.
Prerequisites
- CLI authenticated with
entities:writescope. - Runbooks stored under a
runbooks/directory in your git repo.
Steps
#!/usr/bin/env bash # .git/hooks/post-commit changed=$(git diff-tree --no-commit-id -r --name-only HEAD | grep '^runbooks/') for file in $changed; do [ -f "$file" ] || continue slug="$(basename "$file" .md)" title="$(head -1 "$file" | sed 's/^# //')" echo "[veirox] upserting runbook: $slug" veirox entity update --kind runbook --ref "$slug" --body-file "$file" --title "$title" 2>/dev/null || veirox entity create --kind runbook --slug "$slug" --title "$title" --body-file "$file" done
Make the hook executable:
chmod +x .git/hooks/post-commit
Common pitfalls
- Deleted files: add a check with
git status --porcelainto handle deleted runbooks and callveirox entity delete. - CI pipelines: git hooks don't run in CI. Add an equivalent GitHub Actions step there instead.
See also
- ๐ Reference: veirox entity
- ๐งโ๐ณ Recipe: Bulk-create entities