目录

搭建博客网站


搭建博客网站

折腾 Hugo | GitHub Pages | Github Actions 自动构建发布免费个人网站 - 腾讯云开发者社区-腾讯云 (tencent.com)

ssh-keygen -t rsa -C "email" -f ~/.ssh/gitee_id_rsa_hugo_deploy
echo theme **=** \"hugo-geekdoc\" >> config.toml

1 github actions

name: auto-generate-gitbook
on: #在main分支上进行push时触发
  push:
    branches:
      - main

jobs:
  main-to-gh-pages:
    runs-on: ubuntu-latest

    steps:
      - name: checkout main
        uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
        with:
          ref: main

      - name: install nodejs
        uses: actions/setup-node@v1
        with:
          node-version: 16.x

      - name: configue hexo
        run: |
          npm install --force
          npm install hexo-cli -g
          hexo generate
          touch .nojekyll



      - name: push _book to branch gh-pages
        env:
          TOKEN: ${{ secrets.TOKEN }}
          REF: github.com/xiechaoxin/xiechaoxin.github.io
          MYEMAIL: 15815176957@163.com # !!记得修改为自己github设置的邮箱
          MYNAME: ${{github.repository_owner}}
        run: |
          cd public
          git config --global user.email "${MYEMAIL}"
          git config --global user.name "${MYNAME}"
          git init
          git remote add origin git@${REF}
          git add .
          git commit -m "Updated By Github Actions With Build ${{github.run_number}} of ${{github.workflow}} For Github Pages"
          git branch -M main
          git push --force --quiet "https://xiechaoxin:${TOKEN}@${REF}" main:master