diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 95bc9a4..1542027 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -27,12 +27,47 @@ jobs: - name: Build the application run: npm run kernel:win - name: Upload build to SFTP - uses: wlixcc/SFTP-Deploy-Action@v1.2.4 - with: - server: ${{ secrets.SSH_HOST }} - username: ${{ secrets.SSH_USERNAME }} - password: ${{ secrets.SSH_PASSWORD }} - port: ${{ secrets.SSH_PORT }} - local_path: ./dist/builds/win/x64/* - remote_path: ${{ secrets.SSH_TARGET_DIR }} - sftpArgs: '-o ConnectTimeout=5' \ No newline at end of file + shell: pwsh + run: | + # Установка модуля Posh-SSH + Install-Module -Name Posh-SSH -Force -Scope CurrentUser -AllowClobber + + # Получаем файл для загрузки + $file = Get-ChildItem -Path "dist/builds/win/x64/Rosetta-*.exe" | Select-Object -First 1 + + if (-not $file) { + Write-Error "Build file not found in dist/builds/win/x64/" + exit 1 + } + + Write-Host "Found file: $($file.Name)" + + # Создаем credential + $securePassword = ConvertTo-SecureString "${{ secrets.SSH_PASSWORD }}" -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential("${{ secrets.SSH_USERNAME }}", $securePassword) + + # Подключаемся к SFTP + Write-Host "Connecting to SFTP server..." + $session = New-SFTPSession -ComputerName "${{ secrets.SSH_HOST }}" ` + -Credential $credential ` + -Port ${{ secrets.SSH_PORT }} ` + -AcceptKey + + # Удаляем старые файлы в целевой директории + Write-Host "Cleaning remote directory: ${{ secrets.SSH_TARGET_DIR }}" + $remoteFiles = Get-SFTPChildItem -SessionId $session.SessionId -Path "${{ secrets.SSH_TARGET_DIR }}" + foreach ($remoteFile in $remoteFiles) { + Remove-SFTPItem -SessionId $session.SessionId -Path $remoteFile.FullName -Force + Write-Host "Deleted: $($remoteFile.FullName)" + } + + # Загружаем новый файл + Write-Host "Uploading $($file.Name) to ${{ secrets.SSH_TARGET_DIR }}..." + Set-SFTPItem -SessionId $session.SessionId ` + -Path $file.FullName ` + -Destination "${{ secrets.SSH_TARGET_DIR }}/$($file.Name)" + + # Закрываем соединение + Remove-SFTPSession -SessionId $session.SessionId + + Write-Host "Upload completed successfully!" \ No newline at end of file