chore: 更新依赖 #15
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: Build | |
| on: | |
| push: | |
| branches: ["master"] | |
| workflow_dispatch: | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set pnpm 10 | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Set Node.js 24 | |
| uses: actions/setup-node@v6 | |
| with: | |
| # 选择要使用的 node 版本 | |
| node-version: 24 | |
| # 缓存 pnpm 依赖 | |
| cache: pnpm | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: Install Modules | |
| run: pnpm install --frozen-lockfile | |
| - name: Build on Ubuntu | |
| run: pnpm vite build | |
| - name: Post Build | |
| run: node ./postbuild.js | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: build | |
| path: build/ | |
| - name: Deploy to server via SSH | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| port: ${{ secrets.SSH_PORT }} | |
| source: "build/*" | |
| target: "/tmp/owdy-temp" | |
| strip_components: 1 | |
| rm: true | |
| - name: Execute remote commands | |
| uses: appleboy/ssh-action@v1 | |
| env: | |
| INDEX_DIR: ${{ secrets.DIR }} | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| port: ${{ secrets.SSH_PORT }} | |
| envs: INDEX_DIR | |
| script: | | |
| set -e | |
| if [ ! -d "/$INDEX_DIR/index/" ]; then exit 1; fi | |
| # 移动blog到临时目录 | |
| sudo mv /$INDEX_DIR/index/blog /tmp/ | |
| # 清除目标目录 | |
| sudo rm -rf /$INDEX_DIR/index/* | |
| # 移动文件到目标目录 | |
| sudo mv /tmp/owdy-temp/* /$INDEX_DIR/index/ | |
| # 移动临时目录到blog | |
| sudo mv /tmp/blog /$INDEX_DIR/index/ | |
| # 更改所有者和用户组 | |
| sudo chown -R 1000:1000 /$INDEX_DIR/index/ | |
| # 清理临时目录 | |
| rm -rf /tmp/owdy-temp | |
| echo "Deployment completed successfully!" |