post-receive 845 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # automatically configured by git-annex
  3. if git annex post-receive --help >/dev/null 2>&1; then git annex post-receive; fi
  4. echo "git post-receive hook: starting"
  5. GIT_DIR=.git
  6. WORKING_REPO=../content
  7. CWD=$(pwd)
  8. PYTHON='<path/to/python-virtual-env>'
  9. WWW_SCRIPT='<path/to/build_image_cache.py script>'
  10. CPU_CORE=<number of CPU cores available, run nproc --all on Linux>
  11. while read oldrev newrev ref
  12. do
  13. # synchronize git checkout folder
  14. BRANCH=`echo $ref | cut -d/ -f3`
  15. # avoid error with git-annex `synced` branches
  16. if ! [ $BRANCH = 'synced' ]; then
  17. cd $WORKING_REPO \
  18. && git pull origin $BRANCH \
  19. && git annex sync --content
  20. fi
  21. done
  22. # rebuild all changed images
  23. echo "rebuild updated images..."
  24. CPU_CORE=$CPU_CORE $PYTHON $WWW_SCRIPT build-all-images $WORKING_REPO
  25. echo "git post-receive hook: ending"