使用 hugo 搭建我的博客,GitHub 管理博客資源,GitHub Actions 自動構建更新博客站點。nginx
name: Deploy Blog on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Deploy Blog uses: appleboy/ssh-action@master with: host: ${{secrets.BLOG_ALIYUN_HOST}} username: ${{secrets.BLOG_ALIYUN_USERNAME}} key: ${{secrets.ID_RSA_HUG_BLOG_ALIYUN}} script: | if [ ! -d "kk70-blog-source" ]; then git clone https://github.com/kevin70/blog.git kk70-blog-source fi cd kk70-blog-source git pull --rebase git submodule update --init --recursive docker run --rm -i -v ~/kk70-blog-source:/src klakegg/hugo:0.74.3 if [ ! -d "/usr/share/nginx/kk70.top" ]; then mkdir -p /usr/share/nginx/kk70.top else rm -rf /usr/share/nginx/kk70.top/* fi cp -R public/* /usr/share/nginx/kk70.top/
使用 appleboy/ssh-action 鏈接遠程服務器構建更新 Blog。git
在 GitHub 倉庫的 Settings > Secrets 中配置敏感參數。github
if [ ! -d "kk70-blog-source" ]; then git clone https://github.com/kevin70/blog.git kk70-blog-source fi cd kk70-blog-source git pull --rebase git submodule update --init --recursive
docker run --rm -i -v ~/kk70-blog-source:/src klakegg/hugo:0.74.3
if [ ! -d "/usr/share/nginx/kk70.top" ]; then mkdir -p /usr/share/nginx/kk70.top else rm -rf /usr/share/nginx/kk70.top/* fi cp -R public/* /usr/share/nginx/kk70.top/
主站 https://kk70.top/docker
代碼倉庫 https://github.com/kevin70/blogshell