This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Hexo-theme-snippet to GitHub Pages | |
| on: | |
| push: | |
| branches: [dev] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Asia/Shanghai | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: dev | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install Hexo and dependencies | |
| run: | | |
| npm install -g hexo-cli | |
| npm install | |
| - name: Build static files | |
| run: | | |
| hexo clean | |
| hexo generate | |
| - name: Create deployment info file | |
| run: | | |
| time=$(date '+%Y-%m-%d %H:%M:%S %Z') | |
| cat <<EOF >> public/README.md | |
| ## 自动部署集成日志 | |
| 部署状态 | 集成结果 | 参考值 | |
| ---|---|--- | |
| 完成时间 | $time | yyyy-mm-dd hh:mm:ss | |
| 部署环境 | $RUNNER_OS + node-${{ env.npm_config_node_version }} | windows \| linux \| macos + node-version | |
| 部署类型 | ${{ github.event_name }} | push \| pull_request \| workflow_dispatch | |
| 仓库地址 | ${{ github.repository }} | owner_name/repo_name | |
| 提交分支 | ${{ github.sha }} | commit hash | |
| 提交信息 | ${{ github.event.head_commit.message }} | | |
| Workflow ID | ${{ github.run_id }} | | |
| Workflow NUM | ${{ github.run_number }} | | |
| EOF | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./public | |
| publish_branch: gh-pages |