Advertisement
Guest User

Hexo Deploy (for GitHub Actions)

a guest
May 9th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.72 KB | None | 0 0
  1. name: Build Blog
  2.  
  3. on:
  4.  # Run GH Actions if push to `master` branch
  5.   push:
  6.     branches:
  7.      - master # ps. change to `main` if ur default branch follow's GitHub
  8. jobs:
  9.   deploy-blog:
  10.    # Use macOS Monterey 12
  11.     runs-on: macos-12 # ps. change to `ubuntu-latest` if coz any problem(s)
  12.     steps:
  13.      # Get blog's src
  14.       - name: Get blog source file
  15.         uses: actions/checkout@v3
  16.       # Use Node.js Version 16.x
  17.       - name: Use Node.js 16
  18.         uses: actions/setup-node@v3
  19.         with:
  20.           node-version: 16 # ps. change to `14` if coz any problem(s)
  21.       # Install deps via Yarn
  22.       - name: Install deps
  23.         run: |
  24.          npm install yarn -g
  25.           yarn global add hexo-cli
  26.           yarn install --frozen-lockfile
  27.       # Config system env (SSH, Git, etc.)
  28.       - name: Config env
  29.         env:
  30.           DEPLOY_SEC_KEY: ${{ secrets.DEPLOY_SEC_KEY }} # ps. change to your own value
  31.         run: |
  32.          mkdir -p ~/.ssh/
  33.           echo "$DEPLOY_SEC_KEY" > ~/.ssh/id_rsa
  34.           chmod 777 ~/.ssh/id_rsa
  35.           ssh-keyscan github.com >> ~/.ssh/known_hosts
  36.           git config --global user.name "Hexo Deployment"
  37.           git config --global user.email "khhdeployhexo@fakeaddress.nekohuan.cyou"
  38.         # chmod 777 may coz security problems
  39.       # Deploy using hexo-cli
  40.       - name: Deploy
  41.         run: |
  42.          hexo clean
  43.           hexo d --generate
  44.       # Output to dir `public`
  45.       - name: Output to folder
  46.         uses: peaceiris/actions-gh-pages@v3
  47.         with:
  48.           github_token: ${{ secrets.GITHUB_TOKEN }}
  49.           publish_dir: ./public
  50.           publish_branch: static
  51.  
  52. # GitHub Actions config for deployin' Hexo blog, authored by KuoHuanHuan.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement