Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DocPad: rsync Deploy Script

DocPad: rsync Deploy Script

  • Place deploy.sh in {docpad folder}/bin/
  • Create (or edit) a .env file in your docpad folder with the following values:
#!/bin/bash
DEPLOY_SOURCE_DIR="out/"
DEPLOY_DEST_DIR="~/public_html/"
DEPLOY_SERVER=deploy-server-name
DEPLOY_ACCOUNT=deploy-login-name
  • Create a .deployignore file in docpad folder with the following values:
**.svn
.git
.gitignore
  • Test with ./bin/deploy.sh -n deploy with./bin/deploy.sh
#!/bin/bash
set -o nounset
set -o errexit
NFLAG=""
while getopts ":n" opt; do
case $opt in
n)
NFLAG="-n"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
# Set the environment by loading from the file "environment" in the same directory
DIR="$( cd "$( dirname $( dirname "$0" ) )" && pwd)"
source "$DIR/.env"
echo "Deploying ${DIR}/${DEPLOY_SOURCE_DIR} to ${DEPLOY_ACCOUNT}@${DEPLOY_SERVER}:${DEPLOY_DEST_DIR}"
docpad generate --env static
chmod -R og+Xr out
rsync $NFLAG -rvzp --size-only --delete --exclude-from="$DIR/.deployignore" "${DIR}/${DEPLOY_SOURCE_DIR}" "${DEPLOY_ACCOUNT}@${DEPLOY_SERVER}:${DEPLOY_DEST_DIR}"
@balupton

This comment has been minimized.

Copy link

commented Jun 25, 2013

Would love to see this as a plugin! See http://docpad.org/p/ghpages for a base

@alheka

This comment has been minimized.

Copy link

commented Sep 6, 2013

Thanks, very useful!

I encountered a small problem (source: not found) when I forgot to make deploy.sh executable and executed it with sh ./bin/deploy.sh instead. Otherwise it worked perfectly!

@simonplend

This comment has been minimized.

Copy link

commented Dec 25, 2013

A great starting point, thanks for this!

@mirzaa

This comment has been minimized.

Copy link

commented May 8, 2014

Hi. How can I deploy to a server w/ custom port?

@rhamdeew

This comment has been minimized.

Copy link

commented Sep 10, 2014

mirzaa
You can create ~/.ssh/config file and specify port.
http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

@colorwebdesigner

This comment has been minimized.

Copy link

commented Apr 2, 2019

Please add these changes to the scripts so that you can specify the SSH port number:

.env

#!/bin/bash
DEPLOY_SOURCE_DIR="out/"
DEPLOY_DEST_DIR="~/public_html/"
DEPLOY_SERVER=deploy-server-name

# Add env to specify SSH port
# ------------------------------------
DEPLOY_PORT=22
# ------------------------------------

DEPLOY_ACCOUNT=deploy-login-name

deploy.sh
change rsync call to:

rsync $NFLAG -rvzp --size-only --delete -e "ssh -p ${DEPLOY_PORT}" --exclude-from="$DIR/.deployignore" "${DIR}/${DEPLOY_SOURCE_DIR}" "${DEPLOY_ACCOUNT}@${DEPLOY_SERVER}:${DEPLOY_DEST_DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.