Última atividade 1737471638

github action构建hexo源码,yml文件分享

Revisão 01206c3c0baf0ed320d70ad14ce3ec7def6a876e

deploy.yml Bruto
1name: 自动部署
2
3on:
4 push:
5 branches:
6 - main
7
8 release:
9 types:
10 - published
11
12 workflow_dispatch:
13
14env:
15 TZ: Asia/Shanghai
16
17jobs:
18 deploy:
19 runs-on: ubuntu-latest
20 steps:
21 - name: 检查分支
22 uses: actions/checkout@v3
23 with:
24 ref: main
25
26 - name: 缓存项目 npm 包
27 id: cache-node-modules
28 uses: actions/cache@v3
29 with:
30 path: node_modules
31 key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}
32 restore-keys: |
33 ${{ runner.os }}-nodeModules-
34
35 - name: 安装 Node
36 uses: actions/setup-node@v3
37 with:
38 node-version: "20.x"
39
40 - name: 安装 Hexo
41 run: |
42 npm install hexo-cli --global
43
44 - name: 安装依赖
45 if: steps.cache-node-modules.outputs.cache-hit != 'true'
46 run: |
47 npm install
48
49 - name: 清理文件树
50 run: |
51 npm run clean
52
53 - name: 生成静态文件并压缩
54 run: |
55 npm run build
56
57 - name: 部署
58 run: |
59 cd ./public
60 git init
61 git config user.name "${{ github.actor }}"
62 git config user.email "${{ github.actor }}@users.noreply.github.com"
63 git add .
64 git commit -m "${{ github.event.head_commit.message }}··[$(date +"%Z %Y-%m-%d %A %H:%M:%S")]"
65 git push --force --quiet "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" master:page
66