Skip to content

Instantly share code, notes, and snippets.

@maxfenton
Created May 7, 2026 14:07
Show Gist options
  • Select an option

  • Save maxfenton/bc7a2109617c755f79b35e920ca95b4d to your computer and use it in GitHub Desktop.

Select an option

Save maxfenton/bc7a2109617c755f79b35e920ca95b4d to your computer and use it in GitHub Desktop.
bin/push-content-to-production
#!/usr/bin/env bash
# Push local content to production. ONE-TIME use at go-live to seed Kirby 4 content.
# After go-live, content flows the other way (panel edits → bin/pull-content).
# Defaults to dry run.
#
# Usage:
# bin/push-content-to-production — dry run
# bin/push-content-to-production --real — execute
set -euo pipefail
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
if [ -f "$PROJECT_ROOT/.env" ]; then
source "$PROJECT_ROOT/.env"
fi
: "${DEPLOY_USER:?DEPLOY_USER not set — add to .env}"
: "${DEPLOY_HOST:?DEPLOY_HOST not set — add to .env}"
: "${PRODUCTION_PATH:?PRODUCTION_PATH not set — add to .env}"
if [[ "${1:-}" != "--real" ]]; then
echo "DRY RUN — showing what would be pushed to production (no changes made):"
echo ""
rsync -rlptzv --delete --dry-run \
"$PROJECT_ROOT/content/" \
"$DEPLOY_USER@$DEPLOY_HOST:$PRODUCTION_PATH/content/"
echo ""
echo "Run with --real to push. NOTE: this is a one-time go-live operation."
exit 0
fi
echo "Pushing content to production..."
rsync -rlptzv --delete \
"$PROJECT_ROOT/content/" \
"$DEPLOY_USER@$DEPLOY_HOST:$PRODUCTION_PATH/content/"
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment