Created
August 7, 2010 04:28
-
-
Save jmccartie/512427 to your computer and use it in GitHub Desktop.
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="build" default="help"> | |
<target name="help"> | |
<exec command="phing -h" passthru="true" /> | |
</target> | |
<target name="load.subversion"> | |
<property file="subversion.properties" /> | |
</target> | |
<target name="load.mysql"> | |
<property file="mysql.properties" /> | |
</target> | |
<!--deploy a productionv version of an API I wrote. SVN export with a build number'd folder, then change the symlink --> | |
<target name="api-deploy" depends="load.subversion"> | |
<!--setup properties--> | |
<property name="repo" value="http://${svn.username}:${svn.password}@${svn.base}/api/trunk" /> | |
<!--display repo info--> | |
<exec command="svn info ${repo}" passthru="true" /> | |
<!--ask user for revision num--> | |
<propertyprompt propertyName="svn.exportrevision" promptText="Enter the API revision number to deploy" /> | |
<property name="exportdir" value="/www/builds/api/${svn.exportrevision}" /> | |
<echo>Will deploy to ${exportdir}</echo> | |
<exec command="svn export -r ${svn.exportrevision} ${repo} ${exportdir}" /> | |
<!--make sure the export worked --> | |
<available file="${exportdir}" type="dir" property="export.success" /> | |
<if> | |
<equals arg1="${export.success}" arg2="TRUE" /> | |
<then> | |
<echo message="SVN successfully exported (${export.success})" /> | |
</then> | |
<else> | |
<fail message="There was an error with the SVN export. Most likely, you supplied an incorrect revision number" /> | |
</else> | |
</if> | |
<!--create cache folder --> | |
<mkdir dir="${exportdir}/system/cache" /> | |
<exec command="chmod 777 ${exportdir}/system/cache" /> | |
<echo>API Revision #${svn.exportrevision} exported to ${exportdir}</echo> | |
<!--symlink api.mydomain.com to svn export --> | |
<exec command="ln -nfs ${exportdir} /www/api.mydomain.com" /> | |
</target> | |
<target name="api-rollback"> | |
<!--display possible rollback dirs--> | |
<echo msg="Possible directories to rollback to:" /> | |
<exec command="ls" dir="/www/builds/api/" passthru="true" /> | |
<propertyprompt propertyName="svn.rollbackrevision" promptText="Which revision to rollback to?" /> | |
<property name="rollbackdir" value="/www/builds/api/${svn.rollbackrevision}" /> | |
<!--let's make sure that directory exists--> | |
<available file="${rollbackdir}" type="dir" property="rollback.available" /> | |
<if> | |
<equals arg1="${rollback.available}" arg2="TRUE" /> | |
<then> | |
<exec command="ln -nfs ${rollbackdir} /www/api.mydomain.com" /> | |
<echo>API rolled back to revision # ${svn.rollbackrevision}</echo> | |
</then> | |
<else> | |
<fail message="The rollback revision folder you specified does not exist" /> | |
</else> | |
</if> | |
</target> | |
<!--sync my PRD DB and wordpress wp-content/uploads to DEV --> | |
<target name="sync-dev-db" depends="load.mysql"> | |
<property name="tmp.folder" value="/www/tmp" /> | |
<property name="sql.filename" value="mydomain_prd_tmp.sql" /> | |
<property name="sql.file" value="${tmp.folder}/${sql.filename}" /> | |
<exec command="mysqldump -u${mysql.username} -p${mysql.password} -h ${mysql.server} mydomain_prd > ${sql.file}" /> | |
<reflexive> | |
<fileset dir="${tmp.folder}"> | |
<include pattern="${sql.filename}" /> | |
</fileset> | |
<filterchain> | |
<replaceregexp> | |
<regexp pattern="prd.mydomain.com" replace="dev.mydomain.com" ignoreCase="true"/> | |
</replaceregexp> | |
</filterchain> | |
</reflexive> | |
<!-- next step, MySQL import to mydomain_dev and delete the tmp sql dump --> | |
<exec passthru="true" command="mysql -u${mysql.username} -p${mysql.password} -h ${mysql.server} mydomain_dev < ${sql.file}" /> | |
<delete file="${sql.file}" /> | |
<!-- sync PRD wp-content/uploads to DEV wp-content/uploads --> | |
<exec command="rm -r /www/dev.mydomain.com/wp-content/uploads" /> | |
<exec command="cp -rp /www/prd.mydomain.com/wp-content/uploads /www/dev.mydomain.com/wp-content/" /> | |
<!-- make sure the dev uploads folder exists --> | |
<available file="/www/dev.mydomain.com/wp-content/uploads" type="dir" property="folder.available" /> | |
<if> | |
<equals arg1="${folder.available}" arg2="FALSE" /> | |
<then> | |
<fail message="Something's wrong -- the dev 'uploads' folder isn't where it should be." /> | |
</then> | |
</if> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment