static website automated deploym

2018-11-11  本文已影响85人  老码农不上班

Hugo, The world’s fastest framework for building websites. Caddy, the HTTP/2 web server with automatic HTTPS. Github webhook, which is allows you to build or set up GitHub Apps which subscribe to certain events on GitHub.com. With the three parts, we can build a static website and automatize deployment process. In the post, we can learn how to automated deployment static website

After developed your favorite static website with hugo, I suggest you remove third theme git submodule folder (.git folder in themes/{theme name} and .gitmodules in static website root path).

ssh your_server
sudo apt-get update
sudo apt-get upgrade
curl https://getcaddy.com | sudo bash -s personal http.git,http.hugo
sudo apt-get install hugo
mkdir ~/caddy_log
cat ~/Caddyfile
trustkeeper.io  {
    tls mr.huangwenwei@gmail.com
    gzip
    root /home/deploy/www/trustkeeper.io/public
    log /home/deploy/caddy_log/access.log
    errors /home/deploy/caddy_log/errors.log

    # caddy 的 http.git 插件
    git {
        repo git@github.com:wenweih/trustkeeper.io.git
        path /home/deploy/www/
        clone_args --recursive
        pull_args --recurse-submodules
        key /home/deploy/.ssh/id_rsa
        #then git submodule update --init --recursive
        hook /webhook {webhook secret fill in github}
        then hugo --destination=/home/deploy/www/trustkeeper.io/public
        hook_type github
    }
}

Finally, each git push for the repo, your website would be automated update.
https://trustkeeper.io here we go!

上一篇 下一篇

猜你喜欢

热点阅读