Created
January 4, 2013 22:07
-
-
Save stuartgunter/4457648 to your computer and use it in GitHub Desktop.
Ankyll - a generic Ant script to build and publish Jekyll-based sites to Amazon S3
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="Ankyll" default="prepare" basedir="."> | |
<description> | |
Ankyll is a generic Ant script to build and publish Jekyll-based sites to Amazon S3. | |
It provides a number of independent targets that may be run in isolation, as well as a few "phase" targets that simply depend on sensible targets to achieve their goal. More details can be found in the description of each target. | |
Ankyll relies on a few external tools to be available on the PATH, namely Jekyll, curl and s3cmd. If you do not have all of these tools, certain targets will not work. | |
</description> | |
<!-- the Jekyll generated site directory --> | |
<property name="sitedir" value="_site/"/> | |
<!-- a directory to use for backing up the existing S3 bucket --> | |
<property name="backupdir" value="_backup/"/> | |
<!-- the S3 bucket to interact with - must be prefixed with "s3://" --> | |
<property name="s3bucket" value="s3://YOUR-BUCKET-NAME/"/> | |
<!-- the encoded URL to your sitemap (for submitting to search engines) --> | |
<property name="sitemap" value="http%3A%2F%2Fwww.your-domain.com%2Fsitemap.xml"/> | |
<target name="clean" | |
description="Cleans the project by removing the site and backup directories"> | |
<delete dir="${sitedir}"/> | |
<delete dir="${backupdir}"/> | |
</target> | |
<target name="build" | |
description="Builds the site using Jekyll"> | |
<exec executable="jekyll"> | |
<arg value="--no-auto"/> | |
</exec> | |
</target> | |
<target name="deploy" | |
description="Deploys the site to the configured Amazon S3 bucket"> | |
<exec executable="s3cmd"> | |
<arg value="sync"/> | |
<arg value="--delete-removed"/> | |
<arg value="${sitedir}"/> | |
<arg value="${s3bucket}"/> | |
<arg value="--verbose"/> | |
</exec> | |
</target> | |
<target name="publish-sitemap" | |
description="Publishes the sitemap to search engines (Google and Bing)"> | |
<!-- Bing --> | |
<exec executable="curl"> | |
<arg value="www.bing.com/webmaster/ping.aspx?siteMap=${sitemap}"/> | |
</exec> | |
<!-- Google --> | |
<exec executable="curl"> | |
<arg value="www.google.com/webmasters/tools/ping?sitemap=${sitemap}"/> | |
</exec> | |
</target> | |
<target name="backup" | |
description="Backs up the current data in the Amazon S3 bucket (so we have something to restore if things go wrong)"> | |
<delete dir="${backupdir}"/> | |
<mkdir dir="${backupdir}"/> | |
<exec executable="s3cmd"> | |
<arg value="get"/> | |
<arg value="--recursive"/> | |
<arg value="${s3bucket}"/> | |
<arg value="${backupdir}"/> | |
<arg value="--verbose"/> | |
</exec> | |
</target> | |
<target name="verify-backup" | |
description="Internal use only - just prevents us from unintentionally overwriting an existing backup."> | |
<available file="${backupdir}" property="backup.exists"/> | |
</target> | |
<target name="restore" | |
depends="verify-backup" | |
if="backup.exists" | |
description="Restores the backup directory to the Amazon S3 bucket"> | |
<exec executable="s3cmd"> | |
<arg value="sync"/> | |
<arg value="--delete-removed"/> | |
<arg value="${backupdir}"/> | |
<arg value="${s3bucket}"/> | |
<arg value="--verbose"/> | |
</exec> | |
</target> | |
<target name="prepare-phase" | |
depends="clean,build" | |
description="Prepares the site for deployment for local testing prior to deployment."> | |
</target> | |
<target name="release-phase" | |
depends="backup,deploy,publish-sitemap" | |
description="Releases the site live, taking a backup just before deploying the new site, and finally submitting the sitemap to search engines."> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment