hexo github pages 自动部署
.github\workflows\autodeploy.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| name: 自动部署
on: push: branches: - source
permissions: contents: read pages: write id-token: write
concurrency: group: pages-${{ github.ref }} cancel-in-progress: true
jobs: deploy: runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: 检查分支 uses: actions/checkout@v4 with: ref: source
- name: 安装 Node uses: actions/setup-node@v4 with: node-version: "25.x"
- name: 安装 Hexo run: | export TZ='Asia/Shanghai' npm install hexo-cli -g
- name: 缓存 Hexo uses: actions/cache@v4 id: cache with: path: | node_modules ~/.npm key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}}
- name: 安装依赖 if: steps.cache.outputs.cache-hit != 'true' run: | npm install --save
- name: 生成静态文件 run: | hexo clean hexo generate
- name: 上传静态文件 id: deployment uses: actions/upload-pages-artifact@v3 with: path: ./public
- name: 部署到 GitHub Pages uses: actions/deploy-pages@v4
|