Merge branch 'main' of https://github.com/SR-Studio1-AdventureX25/Mem… #85
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 and Deploy to Server | |
| on: | |
| push: | |
| branches: [ main ] # 当推送到 main 分支时触发 | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build project | |
| run: bun run build | |
| - name: Show build output | |
| run: ls -la dist/ | |
| - name: Install rsync and sshpass | |
| run: sudo apt-get update && sudo apt-get install rsync sshpass -y | |
| - name: Deploy to server | |
| run: | | |
| rsync -avz --delete -e "sshpass -p '${{ secrets.SERVER_SSH_PASSWORD }}' ssh -o StrictHostKeyChecking=no" ./dist/ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:${{ secrets.SERVER_WWWROOT_DIR }} | |
| - name: Deployment completed | |
| run: echo "项目已成功部署到服务器 ${{ secrets.SERVER_IP }}" |