kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

post-receive (1158B)



      1 #!/usr/local/bin/bash
      2 
      3 set -x
      4 set -e
      5 
      6 URL=discord-hook
      7 
      8 while read oldrev newrev ref; do
      9     if [[ $ref =~ .*/master$ ]]; then
     10         logmsg=""
     11         commits=$(git rev-list ${oldrev}..${newrev})
     12         for commit in $commits; do
     13             log=$(git log -1 --pretty=format:'[%h](https://git.kore.io/kore/commit/%H) %cn: %s' $commit)
     14             logmsg="$logmsg $log\\n"
     15         done
     16 
     17         curl -i \
     18             -H "Accept: application/json" \
     19             -H "Content-type: application/json" \
     20             -X POST \
     21             -d "{\"content\": \"${logmsg}\"}" \
     22             $URL
     23     fi
     24 done
     25 
     26 git update-server-info
     27 
     28 ROOT=/var/chroot/kore-site
     29 TARGET=$ROOT/stagit
     30 STATIC=$HOME/src/stagit_static
     31 export TMPDIR=$ROOT/.tmp
     32 
     33 STAGING=`mktemp -d`
     34 
     35 function update_stagit {
     36     mkdir -p $STAGING/$1
     37     pushd $STAGING/$1
     38     stagit $2
     39     cp log.html index.html
     40     cp -R $2 ${STAGING}/${1}.git
     41     rm ${STAGING}/${1}.git/hooks/post-receive
     42     chmod -R +rx ${STAGING}/${1}.git
     43     popd
     44 
     45 }
     46 
     47 update_stagit kore /home/git/kore.git
     48 
     49 cp -R $STATIC/* $STAGING
     50 chmod -R o+rx $STAGING
     51 
     52 rm -rf $ROOT/.old
     53 mv $TARGET $ROOT/.old
     54 mv $STAGING $TARGET
     55 rm -rf $ROOT/.old