20251211 #309
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: Hexo Deploy Automatically | |
| on: | |
| push: | |
| branches: | |
| # The branch where the project source code resides | |
| # 项目源代码所在的分支 | |
| - hexo | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [22.x] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install git-restore-mtime from source | |
| run: | | |
| git log --oneline -n 10 | |
| git clone https://github.com/MestreLion/git-tools.git | |
| sudo install git-tools/git-restore-mtime /usr/local/bin/git-restore-mtime | |
| # Step 3. 恢复文件时间戳 | |
| - name: Restore file modification times | |
| run: | | |
| git restore-mtime | |
| # Step 4. (可选)查看结果 | |
| - name: Verify timestamps | |
| run: | | |
| git restore-mtime -v | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Generate | |
| run: | | |
| npm i && npx hexo g | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_branch: main | |
| publish_dir: ./public | |
| force_orphan: true |