LiuShen revisou este gist 6 months ago. Ir para a revisão
Sem alterações
LiuShen revisou este gist 9 months ago. Ir para a revisão
1 file changed, 10 insertions, 11 deletions
deploy.yml
| @@ -19,32 +19,32 @@ jobs: | |||
| 19 | 19 | runs-on: ubuntu-latest | |
| 20 | 20 | steps: | |
| 21 | 21 | - name: 检查分支 | |
| 22 | - | uses: actions/checkout@main | |
| 22 | + | uses: actions/checkout@v3 | |
| 23 | 23 | with: | |
| 24 | 24 | ref: main | |
| 25 | 25 | ||
| 26 | 26 | - name: 缓存项目 npm 包 | |
| 27 | 27 | id: cache-node-modules | |
| 28 | - | uses: actions/cache@v2 | |
| 28 | + | uses: actions/cache@v3 | |
| 29 | 29 | with: | |
| 30 | 30 | path: node_modules | |
| 31 | - | key: ${{ runner.os }}-${{ matrix.node-version }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }} | |
| 31 | + | key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }} | |
| 32 | 32 | restore-keys: | | |
| 33 | - | ${{ runner.os }}-${{ matrix.node-version }}-nodeModules- | |
| 33 | + | ${{ runner.os }}-nodeModules- | |
| 34 | 34 | ||
| 35 | 35 | - name: 安装 Node | |
| 36 | - | uses: actions/setup-node@main | |
| 36 | + | uses: actions/setup-node@v3 | |
| 37 | 37 | with: | |
| 38 | 38 | node-version: "20.x" | |
| 39 | 39 | ||
| 40 | - | - name: 安装 Hexo 及 压缩插件 | |
| 40 | + | - name: 安装 Hexo | |
| 41 | 41 | run: | | |
| 42 | 42 | npm install hexo-cli --global | |
| 43 | 43 | ||
| 44 | 44 | - name: 安装依赖 | |
| 45 | 45 | if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| 46 | 46 | run: | | |
| 47 | - | npm install --save | |
| 47 | + | npm install | |
| 48 | 48 | ||
| 49 | 49 | - name: 清理文件树 | |
| 50 | 50 | run: | | |
| @@ -58,9 +58,8 @@ jobs: | |||
| 58 | 58 | run: | | |
| 59 | 59 | cd ./public | |
| 60 | 60 | git init | |
| 61 | - | git config --global user.name '${{ secrets.GITHUBUSERNAME }}' | |
| 62 | - | git config --global user.email '${{ secrets.GITHUBEMAIL }}' | |
| 61 | + | git config user.name "${{ github.actor }}" | |
| 62 | + | git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| 63 | 63 | git add . | |
| 64 | 64 | git commit -m "${{ github.event.head_commit.message }}··[$(date +"%Z %Y-%m-%d %A %H:%M:%S")]" | |
| 65 | - | git push --force --quiet "https://${{ secrets.GITHUBUSERNAME }}:${{ secrets.GITEETOKEN }}@gitee.com/${{ secrets.GITHUBUSERNAME }}/blog.git" master:master | |
| 66 | - | git push --force --quiet "https://${{ secrets.GITHUBUSERNAME }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ secrets.GITHUBUSERNAME }}/liushen-blog.git" master:refs/heads/page | |
| 65 | + | git push --force --quiet "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" master:page | |
LiuShen revisou este gist 11 months ago. Ir para a revisão
1 file changed, 66 insertions
deploy.yml(arquivo criado)
| @@ -0,0 +1,66 @@ | |||
| 1 | + | name: 自动部署 | |
| 2 | + | ||
| 3 | + | on: | |
| 4 | + | push: | |
| 5 | + | branches: | |
| 6 | + | - main | |
| 7 | + | ||
| 8 | + | release: | |
| 9 | + | types: | |
| 10 | + | - published | |
| 11 | + | ||
| 12 | + | workflow_dispatch: | |
| 13 | + | ||
| 14 | + | env: | |
| 15 | + | TZ: Asia/Shanghai | |
| 16 | + | ||
| 17 | + | jobs: | |
| 18 | + | deploy: | |
| 19 | + | runs-on: ubuntu-latest | |
| 20 | + | steps: | |
| 21 | + | - name: 检查分支 | |
| 22 | + | uses: actions/checkout@main | |
| 23 | + | with: | |
| 24 | + | ref: main | |
| 25 | + | ||
| 26 | + | - name: 缓存项目 npm 包 | |
| 27 | + | id: cache-node-modules | |
| 28 | + | uses: actions/cache@v2 | |
| 29 | + | with: | |
| 30 | + | path: node_modules | |
| 31 | + | key: ${{ runner.os }}-${{ matrix.node-version }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }} | |
| 32 | + | restore-keys: | | |
| 33 | + | ${{ runner.os }}-${{ matrix.node-version }}-nodeModules- | |
| 34 | + | ||
| 35 | + | - name: 安装 Node | |
| 36 | + | uses: actions/setup-node@main | |
| 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 --save | |
| 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 --global user.name '${{ secrets.GITHUBUSERNAME }}' | |
| 62 | + | git config --global user.email '${{ secrets.GITHUBEMAIL }}' | |
| 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://${{ secrets.GITHUBUSERNAME }}:${{ secrets.GITEETOKEN }}@gitee.com/${{ secrets.GITHUBUSERNAME }}/blog.git" master:master | |
| 66 | + | git push --force --quiet "https://${{ secrets.GITHUBUSERNAME }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ secrets.GITHUBUSERNAME }}/liushen-blog.git" master:refs/heads/page | |