This is a simple script to push new versions of svn or git projects to a production directory on a web server.
- It updates your (already created) working copy. (Do NOT use this working copy for development. You don't want conflicts here - ever!)
- It creates a new release name named release-YYYYMMDDHHIISS
- It runs
svn export $working_copy $EXPORT_TARGET/$releasename
- It deletes a symlink (to your old release)
- It creates a symlink (to the new release)
- It deletes all releases older than ten deploys. Remember that a new deploy always is created when you run the deploy script, even if no changes have been made.
- Check out your svn repo on the production server. Creating a user and home directory for the project might be a good idea - then you can simply add ssh keys for everyone who should have access to deploy updates. On the downside, this means that you don't know who did the deploy.
- You should now have a working copy on the server. Remember that your entire working copy will be deployed - if you only want a subdirectory, i.e. "trunk" or "production", make your checkout more specific.
- Grab
deploy.sh
anddeploy_settings_example.sh
, put them somewhere that makes sense to you. (Perhaps the home directory of the project.) - Have a look in
deploy_settings_example.sh
, change the paths. Rename the file todeploy_settings.sh
when you're done. - Create the export target folder ("releases"). Make sure to give enought privileges to the user who will run the deploy script.
- Move your current production folder into the export target folder. Create a symlink from your old location.
- Check privileges on the symlink. The deploy user needs to be able to delete the symlink and create it again.
- Log in as the correct user and give it a try.
PRUNE is a bash array of regex patterns which will be removed from the release, e.g. you keep .xcf-files in the repository which you don't want to include in the releases.
PRUNE=(".*\.xcf")
All three stages support pre/post hooks:
- update
- export
- symlink
e.g:
export_post_hook(){
cp settings.php ${DST}
}
If a hook returns non-zero the deploy fails. In addition to the variables
provided in settings DST is set to ${EXPORT_TARGET}/${releasename}
.
If you use a custom export_post_hook
and use file pruning you must manually call file_prune
.