Skip to content

Instantly share code, notes, and snippets.

@mattslack
Last active August 4, 2023 20:36
Show Gist options
  • Save mattslack/a8384a796bf92a6fe4a9664e4e06d8ae to your computer and use it in GitHub Desktop.
Save mattslack/a8384a796bf92a6fe4a9664e4e06d8ae to your computer and use it in GitHub Desktop.
Pull craftcms project config down from production on fly.io
#!/bin/sh
# Pull down the current project config from production and overwrite the local
# config files with it.
cd "$(git rev-parse --show-toplevel)" || exit 1
if [ -n "$(git status --porcelain config/project)" ]; then
echo "You have uncommitted changes to your local project config."
exit 1
fi
fly ssh console -C "/app/craft project-config/rebuild" || exit 1
# chaining the ssh commands with && doesn't work for reasons
fly ssh console -C "tar -zcvf project.tgz -C /app/config project" || exit 1
fly ssh console -C "chown -R www-data:www-data ." || exit 1
if [ -f ./project.tgz ]; then
rm ./project.tgz
fi
fly sftp get project.tgz || exit 1
cd config || exit 1
# Remove exising local config files, otherwise you won't notice if a config file has been removed from prod
rm -r project
tar -zxvf ../project.tgz
rm ../project.tgz
# Show the modifications
git status project
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment