Deploy sculpin

Posted on

I created a very simple script to quickly deploy my blog using Sculpin. It was already described on scuplin readme https://sculpin.io/getstarted/#deploy-sculpin, but I have added some improvements for it :)

Firstly create blank script and open it with your favorite editor:

nano deployment

Copy and paste script below and fill it up with your host data:

#!/usr/bin/env bash
DEPLOY_ENV="prod"

#Configuration
DEPLOY_ADDRESS=username@host.com
DEPLOY_DIR="~/path/to/dir/with/blog"

echo "Deploying to: $DEPLOY_ADDRESS"

#Prepare local
echo "Prepare local"
rm -rf "output_$DEPLOY_ENV/"
sculpin generate --env=$DEPLOY_ENV
cp source/.htaccess "output_$DEPLOY_ENV/"

#Copy files
echo "Coping files"
rsync -avze "ssh" "output_$DEPLOY_ENV/" "$DEPLOY_ADDRESS:$DEPLOY_DIR"

I decided to generate a blog before deployment automatically to ensure that freshly generated version with every change will be deployed. Sculpin currently doesn't copy from source/ to output_{env}/ files prefixed with "." so I need to copy .htaccess before deployment (see #121).

Add file execution permissions and move it to bin/:

 chmod +x deployment & mkdir -p bin & mv deployment bin/

Now you can just type:

bin/deployment

and than your blog will be deployed.