feat: Auto-Gitea integration for apps and sites
Streamlit: - App create/deploy now auto-pushes to Gitea when enabled - Add 'gitea init-all' command to initialize repos for all existing apps - Scans all app directories and creates Gitea repos MetaBlogizer: - Site create now auto-pushes to Gitea when token configured - Add 'gitea init-all' command to initialize repos for all existing sites - Iterates over UCI site configs and syncs to Gitea Usage: # Configure Gitea once uci set streamlit.gitea.enabled=1 uci set streamlit.gitea.url='http://192.168.255.1:3000' uci set streamlit.gitea.user='admin' uci set streamlit.gitea.token='<token>' uci commit streamlit # Initialize all existing apps/sites streamlitctl gitea init-all metablogizerctl gitea init-all Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
364f19d421
commit
c1c91f1227
@ -39,6 +39,7 @@ Site Commands:
|
||||
sync <name> Sync site from git repo
|
||||
publish <name> Publish site (create HAProxy vhost)
|
||||
gitea push <name> Create Gitea repo and push site content
|
||||
gitea init-all Initialize Gitea repos for all existing sites
|
||||
emancipate <name> KISS ULTIME MODE - Full exposure workflow:
|
||||
1. DNS A record (Gandi/OVH)
|
||||
2. Vortex DNS mesh publication
|
||||
@ -259,6 +260,13 @@ EOF
|
||||
log_info "Directory: $SITES_ROOT/$name"
|
||||
log_info "Local URL: http://localhost:$port"
|
||||
|
||||
# Auto-push to Gitea if enabled
|
||||
local gitea_token_cfg=$(uci_get main.gitea_token)
|
||||
if [ -n "$gitea_token_cfg" ]; then
|
||||
log_info "Auto-pushing to Gitea..."
|
||||
cmd_gitea_push "$name"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Next: Run 'metablogizerctl publish $name' to create HAProxy vhost"
|
||||
}
|
||||
@ -539,6 +547,69 @@ cmd_gitea_push() {
|
||||
log_info "Push complete: ${gitea_url}/${gitea_user}/${repo_name}"
|
||||
}
|
||||
|
||||
# Initialize Gitea for all existing sites
|
||||
cmd_gitea_init_all() {
|
||||
local gitea_token=$(uci_get main.gitea_token)
|
||||
|
||||
if [ -z "$gitea_token" ]; then
|
||||
log_error "Gitea token not configured"
|
||||
log_info "Configure with:"
|
||||
log_info " uci set metablogizer.main.gitea_url='http://192.168.255.1:3000'"
|
||||
log_info " uci set metablogizer.main.gitea_user='admin'"
|
||||
log_info " uci set metablogizer.main.gitea_token='your-token'"
|
||||
log_info " uci commit metablogizer"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_info "Initializing Gitea repositories for all sites..."
|
||||
echo ""
|
||||
|
||||
local success=0
|
||||
local failed=0
|
||||
|
||||
# Load config and iterate over sites
|
||||
config_load "$CONFIG"
|
||||
|
||||
_init_site_gitea() {
|
||||
local section="$1"
|
||||
local name
|
||||
config_get name "$section" name
|
||||
|
||||
[ -z "$name" ] && return
|
||||
|
||||
# Check if site directory exists
|
||||
if [ ! -d "$SITES_ROOT/$name" ]; then
|
||||
log_warn "[$name] Site directory not found, skipping"
|
||||
return
|
||||
fi
|
||||
|
||||
# Check if already has a repo configured
|
||||
local existing_repo
|
||||
config_get existing_repo "$section" gitea_repo
|
||||
|
||||
if [ -n "$existing_repo" ]; then
|
||||
log_info "[$name] Already linked to $existing_repo, syncing..."
|
||||
else
|
||||
log_info "[$name] Creating Gitea repository..."
|
||||
fi
|
||||
|
||||
if cmd_gitea_push "$name"; then
|
||||
success=$((success + 1))
|
||||
else
|
||||
failed=$((failed + 1))
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
||||
config_foreach _init_site_gitea site
|
||||
|
||||
echo "========================================"
|
||||
echo "Gitea initialization complete"
|
||||
echo " Success: $success"
|
||||
echo " Failed: $failed"
|
||||
echo "========================================"
|
||||
}
|
||||
|
||||
cmd_runtime() {
|
||||
local action="$1"
|
||||
local value="$2"
|
||||
@ -872,8 +943,9 @@ case "${1:-}" in
|
||||
gitea)
|
||||
shift
|
||||
case "${1:-}" in
|
||||
push) shift; cmd_gitea_push "$@" ;;
|
||||
*) echo "Usage: metablogizerctl gitea push <name>"; exit 1 ;;
|
||||
push) shift; cmd_gitea_push "$@" ;;
|
||||
init-all) shift; cmd_gitea_init_all "$@" ;;
|
||||
*) echo "Usage: metablogizerctl gitea {push|init-all} [name]"; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
help|--help|-h) usage ;;
|
||||
|
||||
@ -97,6 +97,7 @@ Gitea Integration:
|
||||
gitea clone <name> <repo> Clone app from Gitea repo
|
||||
gitea pull <name> Pull latest from Gitea
|
||||
gitea push <name> Create Gitea repo and push app content
|
||||
gitea init-all Initialize Gitea repos for all existing apps
|
||||
|
||||
Exposure:
|
||||
emancipate <name> [domain] KISS ULTIME MODE - Full exposure workflow:
|
||||
@ -624,6 +625,13 @@ CONFIGTEMPLATE
|
||||
uci commit "$CONFIG"
|
||||
|
||||
log_info "App '$name' created at $app_dir"
|
||||
|
||||
# Auto-push to Gitea if enabled
|
||||
if [ "$gitea_enabled" = "1" ] && [ -n "$gitea_token" ]; then
|
||||
log_info "Auto-pushing to Gitea..."
|
||||
cmd_gitea_push "$name"
|
||||
fi
|
||||
|
||||
log_info "Next steps:"
|
||||
log_info " 1. Edit $app_dir/app.py"
|
||||
log_info " 2. Add dependencies to $app_dir/requirements.txt"
|
||||
@ -716,6 +724,12 @@ cmd_app_deploy() {
|
||||
|
||||
log_info "App '$name' deployed to $app_dir"
|
||||
|
||||
# Auto-push to Gitea if enabled
|
||||
if [ "$gitea_enabled" = "1" ] && [ -n "$gitea_token" ]; then
|
||||
log_info "Auto-pushing to Gitea..."
|
||||
cmd_gitea_push "$name"
|
||||
fi
|
||||
|
||||
# Auto-package for P2P distribution
|
||||
if [ -x /usr/sbin/secubox-content-pkg ]; then
|
||||
log_info "Packaging app for P2P distribution..."
|
||||
@ -1122,6 +1136,54 @@ cmd_gitea_push() {
|
||||
log_info "Push complete: ${gitea_url}/${gitea_user}/${repo_name}"
|
||||
}
|
||||
|
||||
# Initialize Gitea for all existing apps
|
||||
cmd_gitea_init_all() {
|
||||
require_root
|
||||
load_config
|
||||
|
||||
if [ "$gitea_enabled" != "1" ]; then
|
||||
log_error "Gitea integration not enabled"
|
||||
log_info "Enable with: uci set streamlit.gitea.enabled=1 && uci commit streamlit"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$gitea_token" ]; then
|
||||
log_error "Gitea token not configured"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_info "Initializing Gitea repositories for all apps..."
|
||||
echo ""
|
||||
|
||||
local success=0
|
||||
local failed=0
|
||||
|
||||
# Process all app directories
|
||||
if [ -d "$APPS_PATH" ]; then
|
||||
for app_dir in "$APPS_PATH"/*/; do
|
||||
[ -d "$app_dir" ] || continue
|
||||
local name=$(basename "$app_dir")
|
||||
|
||||
# Skip if already has a repo configured
|
||||
local existing_repo=$(uci -q get ${CONFIG}.${name}.repo)
|
||||
if [ -n "$existing_repo" ]; then
|
||||
log_info "[$name] Already linked to $existing_repo, syncing..."
|
||||
cmd_gitea_push "$name" && success=$((success + 1)) || failed=$((failed + 1))
|
||||
else
|
||||
log_info "[$name] Creating Gitea repository..."
|
||||
cmd_gitea_push "$name" && success=$((success + 1)) || failed=$((failed + 1))
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
fi
|
||||
|
||||
echo "========================================"
|
||||
echo "Gitea initialization complete"
|
||||
echo " Success: $success"
|
||||
echo " Failed: $failed"
|
||||
echo "========================================"
|
||||
}
|
||||
|
||||
# ===========================================
|
||||
# KISS ULTIME MODE - Emancipate
|
||||
# ===========================================
|
||||
@ -1553,11 +1615,12 @@ case "${1:-}" in
|
||||
gitea)
|
||||
shift
|
||||
case "${1:-}" in
|
||||
setup) shift; cmd_gitea_setup "$@" ;;
|
||||
clone) shift; cmd_gitea_clone "$@" ;;
|
||||
pull) shift; cmd_gitea_pull "$@" ;;
|
||||
push) shift; cmd_gitea_push "$@" ;;
|
||||
*) echo "Usage: streamlitctl gitea {setup|clone|pull|push}"; exit 1 ;;
|
||||
setup) shift; cmd_gitea_setup "$@" ;;
|
||||
clone) shift; cmd_gitea_clone "$@" ;;
|
||||
pull) shift; cmd_gitea_pull "$@" ;;
|
||||
push) shift; cmd_gitea_push "$@" ;;
|
||||
init-all) shift; cmd_gitea_init_all "$@" ;;
|
||||
*) echo "Usage: streamlitctl gitea {setup|clone|pull|push|init-all}"; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user