利用git actions自动部署vuepress-theme-hope到远程服务器上

81 阅读1分钟

截止2024-12-30日,插件版本都是最新的。 easingthemes/ssh-deploy@main里的ssh连接参数和x-shell远程ssh连接的参数一致;

name: Deploy Web

on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 'latest'

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: pnpm

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Build VuePress Web
        run: pnpm docs:build

      - name: Deploy to Server
        uses: easingthemes/ssh-deploy@main
        with:
            SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
            REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
            REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
            REMOTE_USER: ${{ secrets.REMOTE_USER }}
            ARGS: "-rlgoDzvc -i --delete"
            SOURCE: "src/.vuepress/dist/"
            TARGET: ${{ secrets.REMOTE_TARGET }}