Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save maxfenton/0c85454ed8e26884c889df6aa653c9ee to your computer and use it in GitHub Desktop.
bin/push-content-to-staging
#!/usr/bin/env bash
# Push local content to staging. Defaults to dry run.
#
# Usage:
# bin/push-content-to-staging — dry run
# bin/push-content-to-staging --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}"
: "${STAGING_PATH:?STAGING_PATH not set — add to .env}"
if [[ "${1:-}" != "--real" ]]; then
echo "DRY RUN — showing what would be pushed to staging (no changes made):"
echo ""
rsync -rlptzv --delete --dry-run \
"$PROJECT_ROOT/content/" \
"$DEPLOY_USER@$DEPLOY_HOST:$STAGING_PATH/content/"
echo ""
echo "Run with --real to push these changes to staging."
exit 0
fi
echo "Pushing content to staging..."
rsync -rlptzv --delete \
"$PROJECT_ROOT/content/" \
"$DEPLOY_USER@$DEPLOY_HOST:$STAGING_PATH/content/"
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment