Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #11 from twangboy/add_script #12

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions .github/workflows/parse_cab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
$matrix = 1..$chunks

# Convert the matrix to JSON
$matrix_json = $matrix | ConvertTo-Json
$matrix_json = $matrix | ConvertTo-Json -Compress

# Set output
Write-Output "matrix=$matrix_json" | Out-File -FilePath $env:$GITHUB_OUTPUT -Encoding utf8 -Append
Write-Output "matrix=$matrix_json" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append

parse-cab:
runs-on: windows-latest
Expand All @@ -50,34 +50,36 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: wsus-updates-${{ matrix.chunk }}
path: artifacts/wsus_updates_${{ matrix.chunk }}.json
path: wsus_updates_${{ matrix.chunk }}.json
retention-days: 1

join-artifacts:
needs: parse-cab
runs-on: windows-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: all-artifacts
merge-multiple: true
- name: show me stuff
run: |
Get-ChildItem . -Recurse | Select FullName | Write-Host
- name: Merge Artifacts
run: |
$json_files = Get-ChildItem -Path "all-artifacts" -Filter *.json
$merged_data = @()
$json_files = Get-ChildItem -Path . -Filter *.json
$merged_data = @{}
$json_files | ForEach-Object {
$json_content = Get-Content -Path $_.FullName | ConvertFrom-Json
$merged_data += $json_content
$json_content.PSObject.Properties | ForEach {
$merged_data[$_.Name] = $_.Value
}
}
$json_data = $merged_data | ConvertTo-Json | Out-String
$json_data = $merged_data | ConvertTo-Json -Depth 10 | Out-String
$json_file = "wsus_updates.json"
$UTF8NoBOM = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($json_file, $json_data, $UTF8NoBOM)
- name: Clean up Chunk JSON Files
run: |
Write-Host "Cleaning up chunk JSON files..."
Remove-Item -path all-artifacts -Recurse -Force
- name: Upload Merged Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wsus_updates
path: artifacts/wsus_updates.json
path: wsus_updates.json
26 changes: 14 additions & 12 deletions wsusscn2_parse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,20 @@ function Expand-Cab {
################################################################################
Write-Host "Generate VWin Data from wsusscn2.cab"

# Downloading
Write-Verbose "URI: $uri"
Write-Verbose "File: $cab_file"
$elapsed_time = $(Get-Date) - $start_time
$total_time = "{0:HH:mm:ss}" -f ([datetime]$elapsed_time.Ticks)
Write-Host "- Downloading wsusscn2.cab ($total_time): " -NoNewline
Invoke-WebRequest -Uri $uri -OutFile $cab_file -UseBasicParsing
if ( Test-Path -Path $cab_file ) {
Write-Host "SUCCESS" -ForegroundColor Green
} else {
Write-Host "FAILED" -ForegroundColor Red
exit 1
if ( ! ( Test-Path -Path $cab_file ) ) {
# Downloading
Write-Verbose "URI: $uri"
Write-Verbose "File: $cab_file"
$elapsed_time = $(Get-Date) - $start_time
$total_time = "{0:HH:mm:ss}" -f ([datetime]$elapsed_time.Ticks)
Write-Host "- Downloading wsusscn2.cab ($total_time): " -NoNewline
Invoke-WebRequest -Uri $uri -OutFile $cab_file -UseBasicParsing
if ( Test-Path -Path $cab_file ) {
Write-Host "SUCCESS" -ForegroundColor Green
} else {
Write-Host "FAILED" -ForegroundColor Red
exit 1
}
}

# Extracting main cab
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.