Combine build type detection and GAS sending steps

This commit is contained in:
amd64fox 2025-11-14 02:15:12 +03:00
parent d15b5fbc32
commit 0eebb89e76

View file

@ -36,67 +36,60 @@ jobs:
echo 'EOF'
} >> "$GITHUB_OUTPUT"
get-build-type:
get-build-and-send:
runs-on: windows-latest
needs: version-search
if: success() && needs.version-search.outputs.versions
continue-on-error: true
outputs:
build_type: ${{ steps.get_build_type.outputs.build_type }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Get Win64 URL and determine build type
id: get_build_type
- name: Get build type and send to GAS
shell: pwsh
run: |
$versionsJson = '${{ needs.version-search.outputs.versions }}' | ConvertFrom-Json
$win64Url = $versionsJson.WIN64
if ($win64Url) {
./get-build-info.ps1 -Url $win64Url
} else {
"build_type=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
}
send-to-gas:
runs-on: ubuntu-latest
needs: [version-search, get-build-type]
if: success() && needs.version-search.outputs.versions
steps:
- name: Send data to Google Apps Script
env:
g: ${{ secrets.GOOGLE_APPS_URL }}
GOOGLE_APPS_URL: ${{ secrets.GOOGLE_APPS_URL }}
versions: ${{ needs.version-search.outputs.versions }}
build_type: ${{ needs.get-build-type.outputs.build_type }}
source: ${{ github.event.client_payload.s }}
run: |
if [ -z "$versions" ]; then
echo "Versions data is empty. Skipping."
exit 0
fi
# Получаем build type
$versionsJson = $env:versions | ConvertFrom-Json
$win64Url = $versionsJson.WIN64
if [ "$build_type" = "false" ]; then
final_json=$(echo "$versions" | jq \
--argjson buildType false \
--arg source "$source" \
'. + {buildType: $buildType, source: $source}')
else
final_json=$(echo "$versions" | jq \
--arg buildType "$build_type" \
--arg source "$source" \
'. + {buildType: $buildType, source: $source}')
fi
if ($win64Url) {
./get-build-info.ps1 -Url $win64Url
$buildType = (Get-Content $env:GITHUB_OUTPUT | Select-String "build_type=(.+)" | ForEach-Object { $_.Matches.Groups[1].Value })
} else {
$buildType = "false"
}
echo "Отправка данных на GAS..."
Write-Host "🔧 Build Type: $buildType"
response=$(curl -s -L --post301 --post302 --post303 -X POST "$g" \
-H "Content-Type: application/json" \
--data-raw "$final_json")
# Формируем финальный JSON
$versionsObj = $env:versions | ConvertFrom-Json
if echo "$response" | grep -q "<!DOCTYPE html>"; then
echo "Получен HTML ответ"
echo "Проверьте сообщение в Telegram - если оно пришло, значит скрипт работает"
else
echo "Ответ от GAS: $response"
fi
if ($buildType -eq "false") {
$versionsObj | Add-Member -NotePropertyName "buildType" -NotePropertyValue $false -Force
} else {
$versionsObj | Add-Member -NotePropertyName "buildType" -NotePropertyValue $buildType -Force
}
$versionsObj | Add-Member -NotePropertyName "source" -NotePropertyValue $env:source -Force
$finalJson = $versionsObj | ConvertTo-Json -Compress
Write-Host "Отправка данных на GAS..."
Write-Host "Версия: $($versionsObj.version)"
# Отправляем в GAS через PowerShell
try {
$response = Invoke-WebRequest -Uri $env:GOOGLE_APPS_URL `
-Method POST `
-ContentType "application/json" `
-Body $finalJson `
-UseBasicParsing
Write-Host "Ответ от GAS: $($response.Content)"
} catch {
Write-Host "Ошибка при отправке в GAS: $_"
exit 1
}