[Makefile] Publish Static Website to GitHub Project Pages


First install ghp-import via pip (Ubuntu Linux 16.10 as example):

$ sudo apt-get install python-pip
$ sudo pip install ghp-import

Then in Makefile (assume your static website are located in /home/usrname/dev/mywebsite/):

publish_to_github_project_pages:
      cd /home/usrname/dev/; ghp-import mywebsite; git push origin gh-pages

Note that I put several commands in one line. If your Makefile is not located in /home/usrname/dev/, the following will not work:

publish_to_github_project_pages:
      # wrong way
      cd /home/usrname/dev/
      ghp-import mywebsite
      git push origin gh-pages

Because when GNU make executes every line of command, it executes the command at current directory of of Makefile. So when ghp-import try to find mywebsite directory in current directory, it will find nothing and report error.


Tested on Ubuntu Linux 16.10, GNU make 4.1-9.


References:

[1]
[2]Publishing to GitHub - Tips — Pelican 3.7.1.dev0 documentation