Last active
January 4, 2016 06:59
-
-
Save inverse/8585975 to your computer and use it in GitHub Desktop.
Basic CodeIgniter deployment using Mercurial via SSH.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="deploy" default="help" basedir="."> | |
<!-- | |
Required properties: | |
Repo to pull from | |
- repo | |
Location to deploy too | |
- deploy.location | |
Host to deploy to | |
- host | |
Username of ssh | |
- username- | |
SSH key file | |
- keyfile= | |
Key file passphase | |
- passphase | |
--> | |
<loadproperties srcFile="local.properties"/> | |
<tstamp> | |
<format property="timestamp" pattern="yyyy-MM-dd_HHmmss"/> | |
</tstamp> | |
<!-- New public_html directory --> | |
<property name="public_html.dir" value="public_html_${timestamp}" /> | |
<!-- Update website --> | |
<target name="update"> | |
<ssh command="cd ${deploy.location}; hg clone ${repo} ${public_html.dir}; cd ${public_html.dir}; rm -rf .hg .hgignore; sed -i "s/'development');/'production');/" index.php" /> | |
<ssh command="cd ${deploy.location}; old_path=0; if test -d public_html; then old_path=$(readlink -f public_html); fi; ln -s ${public_html.dir} public_html_tmp && mv -Tf public_html_tmp public_html; rm -rf $$old_path" /> | |
</target> | |
<!-- Macro for running ssh commands easier --> | |
<macrodef name="ssh"> | |
<attribute name="command"/> | |
<sequential> | |
<sshexec host="${host}" username="${username}" keyfile="${keyfile}" passphrase="${passphase}" trust="true" command="@{command}"/> | |
</sequential> | |
</macrodef> | |
<!-- Display help --> | |
<target name="help"> | |
<echo message="Use this script to deploy CodeIgniter website to production" /> | |
<echo message=" update - deploy the website to live" /> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment