git-push-konnos.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env bash
  2. # Push Briven main → Konnos ONLY (no GitHub).
  3. #
  4. # Dokploy auto-deploy for briven-france is wired to:
  5. # https://code.konnos.org/flndrn/Briven.git (customGit)
  6. # so production rebuilds from Konnos pushes, not GitHub.
  7. #
  8. # Usage:
  9. # ./scripts/git-push-konnos.sh setup # configure remotes only
  10. # ./scripts/git-push-konnos.sh # configure + push main
  11. # ./scripts/git-push-konnos.sh main # configure + push that branch
  12. set -euo pipefail
  13. KONNOS_URL="${BRIVEN_KONNOS_URL:-https://code.konnos.org/flndrn/Briven.git}"
  14. ARG="${1:-main}"
  15. if [[ "$ARG" == "setup" ]]; then
  16. DO_PUSH=0
  17. BRANCH="main"
  18. else
  19. DO_PUSH=1
  20. BRANCH="$ARG"
  21. fi
  22. # origin = Konnos only (fetch + push). No GitHub dual-push.
  23. if git remote get-url origin >/dev/null 2>&1; then
  24. git remote set-url origin "$KONNOS_URL"
  25. # Drop any extra push URLs (old dual-push config)
  26. # re-set single push URL
  27. git remote set-url --push origin "$KONNOS_URL" 2>/dev/null || true
  28. else
  29. git remote add origin "$KONNOS_URL"
  30. fi
  31. # Keep named konnos remote as alias
  32. if git remote get-url konnos >/dev/null 2>&1; then
  33. git remote set-url konnos "$KONNOS_URL"
  34. else
  35. git remote add konnos "$KONNOS_URL"
  36. fi
  37. # Remove accidental github-only remote if present as separate name
  38. # (do not delete "github" if user has one; only clean dual-push on origin)
  39. echo "origin fetch: $(git remote get-url origin)"
  40. echo "origin push: $(git remote get-url --push origin 2>/dev/null || git remote get-url origin)"
  41. echo "konnos: $(git remote get-url konnos)"
  42. if [[ "$DO_PUSH" -eq 1 ]]; then
  43. echo "Pushing '${BRANCH}' → Konnos only (code.konnos.org)…"
  44. git push -u origin "$BRANCH"
  45. echo "Done. Konnos is source of truth. Dokploy should auto-deploy if webhook/autoDeploy is on."
  46. fi