Pushing MediaWiki-powered wikis to GitHub

Just yesterday, I set up a cronjob to regularly push the RaumZeitLabor wiki to GitHub. Why? Because people wanted to search and aggregate the wiki like they would with normal text files. And because I like GitHubs repository graphs and wanted to use them for the wiki as well.

Installation

So lets get to it. I used Git-Mediawiki for the job, which allows you to interact with a MediaWiki-installation just like a normal git repository. The installation is pretty easy (I’m using Debian Testing):

Working with your wiki

That was it with the installation. Now you can clone a wiki like so:

Be careful, as this is usually not the URL you see when browsing the wiki, but the path you see when doing edits or similar operations on your wiki.

Wrong path.

Wrong path.

Right path.

Right path.

To update your repository to the current state of the wiki, use

Automation

In the given scenario, the github repo was supposed to be updated regularly.

To do this, a deploy key pair for GitHub was needed.

The public key of this key pair was then added to the GitHub repository.
github_deploy_key

A custom SSH host was used to incorporate the key file. This was done in .ssh/config

Initializing the git repository may take a while, depending on the size of your wiki. Don’t try Wikipedia.

The actual update script is pretty short.

Don’t forget to make it executable.

Last but no least, a cronjob was scheduled to run that script once a day.

13. January 2013 by tiefpunkt
Categories: Allgemein | Tags: , , , , | Comments Off on Pushing MediaWiki-powered wikis to GitHub