#!/bin/bash repreproDir="/var/cache/reprepro" codename="stable" while read oldrev newrev ref do if [[ ! $ref =~ .*/master$ ]] then echo "Ref $ref received. Doing nothing." continue fi echo "Master ref received. Deploying master branch to production." buildDir="/tmp/git-deploy/$newrev" srcDir="$buildDir/src" echo "Exporting to a temporary directory." rm -rf "$buildDir" mkdir -p "$srcDir" git --work-tree="$srcDir" --git-dir="$PWD" checkout -f echo "Building Debian packages." (cd $srcDir && debuild -uc -us -b) echo "Uploading Debian packages." cut -d" " -f1 $srcDir/debian/files | while read debFile do if [[ ! $debFile =~ .*\.deb$ ]] then continue fi echo "Uploading $debFile." reprepro -b $repreproDir includedeb $codename "$buildDir/$debFile" done echo "Cleaning temporary directory." rm -rf "$buildDir" done