Deploy VSIX to Server #13
Workflow file for this run
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: Deploy VSIX to Server | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to deploy (e.g., 2.7.1). Leave empty to use current version.' | |
| required: false | |
| default: '' | |
| jobs: | |
| deploy-to-server: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [ -n "${{ github.event.inputs.version }}" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| else | |
| VERSION=$(node -p "require('./src/package.json').version") | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Download VSIX from Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| gh release download "v${VERSION}" --pattern "zgsm-${VERSION}.vsix" --dir bin | |
| - name: Install sshpass | |
| run: sudo apt-get install -y sshpass | |
| - name: Create remote directory | |
| id: mkdir | |
| continue-on-error: true | |
| env: | |
| SSH_HOST: ${{ secrets.SSH_HOST }} | |
| SSH_PORT: ${{ secrets.SSH_PORT }} | |
| SSH_USER: ${{ secrets.SSH_USER }} | |
| SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | |
| run: | | |
| echo "Creating remote directory /home/zhuge/costrict.ai/nginx/html/plugin/download" | |
| sshpass -p "${SSH_PASSWORD}" ssh \ | |
| -o StrictHostKeyChecking=no \ | |
| -o UserKnownHostsFile=/dev/null \ | |
| -p "${SSH_PORT:-22}" \ | |
| "${SSH_USER}@${SSH_HOST}" \ | |
| "mkdir -p /home/zhuge/costrict.ai/nginx/html/plugin/download" | |
| echo "Directory created successfully" | |
| - name: Upload to server via SSH | |
| id: upload | |
| continue-on-error: true | |
| env: | |
| SSH_HOST: ${{ secrets.SSH_HOST }} | |
| SSH_PORT: ${{ secrets.SSH_PORT }} | |
| SSH_USER: ${{ secrets.SSH_USER }} | |
| SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| SOURCE_FILE="bin/zgsm-${VERSION}.vsix" | |
| TARGET_PATH="/home/zhuge/costrict.ai/nginx/html/plugin/download/zgsm-${VERSION}.vsix" | |
| echo "Uploading ${SOURCE_FILE} to ${SSH_HOST}:${TARGET_PATH}" | |
| sshpass -p "${SSH_PASSWORD}" scp \ | |
| -o StrictHostKeyChecking=no \ | |
| -o UserKnownHostsFile=/dev/null \ | |
| -P "${SSH_PORT:-22}" \ | |
| "${SOURCE_FILE}" \ | |
| "${SSH_USER}@${SSH_HOST}:${TARGET_PATH}" | |
| echo "Upload completed successfully" | |
| - name: Cleanup old versions | |
| id: cleanup | |
| continue-on-error: true | |
| env: | |
| SSH_HOST: ${{ secrets.SSH_HOST }} | |
| SSH_PORT: ${{ secrets.SSH_PORT }} | |
| SSH_USER: ${{ secrets.SSH_USER }} | |
| SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| echo "Cleaning up old versions in /home/zhuge/costrict.ai/nginx/html/plugin/download" | |
| sshpass -p "${SSH_PASSWORD}" ssh \ | |
| -o StrictHostKeyChecking=no \ | |
| -o UserKnownHostsFile=/dev/null \ | |
| -p "${SSH_PORT:-22}" \ | |
| "${SSH_USER}@${SSH_HOST}" \ | |
| "cd /home/zhuge/costrict.ai/nginx/html/plugin/download && ls -la zgsm-*.vsix 2>/dev/null | grep -v 'zgsm-${VERSION}.vsix' | awk '{print \$9}' | xargs -r rm -f" | |
| echo "Cleanup completed" | |
| - name: Report upload status | |
| if: steps.upload.outcome == 'failure' | |
| run: | | |
| echo "::warning::SSH upload failed. VSIX was not uploaded to server." | |
| echo "Please manually upload bin/zgsm-${{ steps.version.outputs.version }}.vsix to /home/zhuge/costrict.ai/nginx/html/plugin/download" |