Browse Source

ci 上传脚本,使用ssh方式

dengdx 3 weeks ago
parent
commit
7c04e40d5f
1 changed files with 14 additions and 8 deletions
  1. 14 8
      .github/workflows/build-linux-arm-appimage.yml

+ 14 - 8
.github/workflows/build-linux-arm-appimage.yml

@@ -53,15 +53,21 @@ jobs:
       - name: Set timestamp version
         run: echo "VERSION=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_ENV
 
-      - name: Upload dist/h5/ to server
-        uses: burnett01/rsync-deployments@6.0.0
+      - name: Create version directory on server
+        uses: appleboy/ssh-action@v1.0.0
         with:
-          switches: -avz --delete
-          path: dist/h5/  # 本地构建产物目录
-          remote_path: "${{ secrets.DEPLOY_PATH }}/${{ env.VERSION }}/"  # 服务器目标路径
-          remote_host: ${{ secrets.DEPLOY_HOST }}
-          remote_user: ${{ secrets.DEPLOY_USER }}
-          remote_key: ${{ secrets.DEPLOY_KEY }}
+          host: ${{ secrets.DEPLOY_HOST }}
+          username: ${{ secrets.DEPLOY_USER }}
+          key: ${{ secrets.DEPLOY_KEY }}
+          script: mkdir -p ${{ secrets.DEPLOY_PATH }}/${{ env.VERSION }}
+
+      - name: Upload files via rsync
+        run: |
+          # 去掉 --delete 参数,只上传/更新文件,不删除目标目录任何内容
+          rsync -avz dist/h5/ \
+            ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.DEPLOY_PATH }}/${{ env.VERSION }}/
+        env:
+          SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
 
   # build-pkg:
   #   needs: deploy-h5-production