|
1 | 1 | # CD pipeline to download packages from Commercial and/or Community downloads API and run Grype security scan |
2 | 2 |
|
3 | 3 | # test inputs: |
4 | | - # product: chef |
5 | | - # product-version: 19.0.6 |
| 4 | + # product: chef (or chef-workstation) |
| 5 | + # product-version: 18.8.54 (for chef), 25.12.1102 (for chef-workstation) |
6 | 6 | # channel: stable |
7 | 7 | # architecture: x86_64 |
8 | 8 | # os-platform: both (ubuntu and windows) |
9 | | - # os-platform-version: not specified |
| 9 | + # os-platform-version: 24.04 (TODO: make this selectable by Windows and linux separately later) |
10 | 10 | # download-site: commercial |
11 | 11 | # license-id: (not specified, uses secret) |
12 | 12 |
|
@@ -262,17 +262,39 @@ jobs: |
262 | 262 | echo "Using license ID in download URL" |
263 | 263 | fi |
264 | 264 | fi |
| 265 | + echo "Full DOWNLOAD_URL: ${DOWNLOAD_URL}" |
| 266 | + echo "DOWNLOAD_URL=${DOWNLOAD_URL}" >> $GITHUB_ENV |
265 | 267 |
|
266 | | - # download the specified product from https://chefdownload-community.chef.io/stable/<PRODUCT>/download?p=<PLATFORM>&pv=<PLATFORM_VERSION>&m=<ARCHITECTURE>&v=<PRODUCT_VERSION> |
267 | | - # OR https://chefdownload-commercial.chef.io/stable/chef/download?p=windows&pv=11&m=x86_64&v=25.12.1102&license_id=LICENSE_ID |
268 | | - |
269 | 268 | # Download the package |
270 | 269 | curl -L -o /tmp/package_downloaded "${DOWNLOAD_URL}" |
271 | 270 | |
272 | | - # Extract the package based on its type (assuming .tar.gz for this example) |
273 | | - mkdir -p /tmp/extracted_packages |
274 | | - tar -xzf /tmp/package_downloaded -C /tmp/extracted_packages |
275 | | - echo "Package downloaded and extracted to /tmp/extracted_packages" |
| 271 | + # Handle package extraction based on platform |
| 272 | + if [ "${{ inputs.os-platform }}" = "ubuntu" ]; then |
| 273 | + # Ubuntu downloads are .deb packages - install them |
| 274 | + echo "Installing .deb package..." |
| 275 | + sudo dpkg -i /tmp/package_downloaded |
| 276 | + |
| 277 | + # Echo where it was installed |
| 278 | + echo "Package installed. Listing installed files:" |
| 279 | + dpkg -L ${{ inputs.product }} || dpkg -L $(dpkg -I /tmp/package_downloaded | grep Package: | awk '{print $2}') |
| 280 | + |
| 281 | + # Set extraction path for grype scan |
| 282 | + mkdir -p /tmp/extracted_packages |
| 283 | + # Copy installed files to extraction directory for scanning |
| 284 | + echo "Copying installed files for scanning..." |
| 285 | + if [ "${{ inputs.product }}" = "chef" ]; then |
| 286 | + sudo cp -r /opt/chef /tmp/extracted_packages/ 2>/dev/null || true |
| 287 | + elif [ "${{ inputs.product }}" = "chef-workstation" ]; then |
| 288 | + sudo cp -r /opt/chef-workstation /tmp/extracted_packages/ 2>/dev/null || true |
| 289 | + else |
| 290 | + sudo cp -r /opt/${{ inputs.product }} /tmp/extracted_packages/ 2>/dev/null || true |
| 291 | + fi |
| 292 | + else |
| 293 | + # Extract the package based on its type (assuming .tar.gz for non-Ubuntu) |
| 294 | + mkdir -p /tmp/extracted_packages |
| 295 | + tar -xzf /tmp/package_downloaded -C /tmp/extracted_packages |
| 296 | + echo "Package downloaded and extracted to /tmp/extracted_packages" |
| 297 | + fi |
276 | 298 |
|
277 | 299 | ls -l /tmp/extracted_packages |
278 | 300 |
|
@@ -365,11 +387,37 @@ jobs: |
365 | 387 | # Download the package |
366 | 388 | Invoke-WebRequest -Uri $DownloadUrl -OutFile "$env:TEMP\package_downloaded" -FollowRelLink |
367 | 389 |
|
368 | | - # Extract the package based on its type (assuming .zip for Windows) |
| 390 | + # Handle package extraction/installation based on platform |
369 | 391 | $ExtractPath = "$env:TEMP\extracted_packages" |
370 | 392 | New-Item -ItemType Directory -Force -Path $ExtractPath |
371 | | - Expand-Archive -Path "$env:TEMP\package_downloaded" -DestinationPath $ExtractPath -Force |
372 | | - Write-Host "Package downloaded and extracted to $ExtractPath" |
| 393 | + |
| 394 | + if ("${{ inputs.os-platform }}" -eq "windows") { |
| 395 | + # Windows downloads are .msi packages - install them |
| 396 | + Write-Host "Installing .msi package..." |
| 397 | + Start-Process msiexec.exe -ArgumentList "/i", "$env:TEMP\package_downloaded", "/qn", "/norestart" -Wait |
| 398 | + |
| 399 | + # Echo where it was installed |
| 400 | + Write-Host "Package installed. Common installation paths:" |
| 401 | + if (Test-Path "C:\opscode\chef") { |
| 402 | + Write-Host "Found installation at: C:\opscode\chef" |
| 403 | + Get-ChildItem -Path "C:\opscode\chef" -Recurse -Depth 1 |
| 404 | + Copy-Item -Path "C:\opscode\chef" -Destination $ExtractPath -Recurse -Force |
| 405 | + } |
| 406 | + if (Test-Path "C:\opscode\chef-workstation") { |
| 407 | + Write-Host "Found installation at: C:\opscode\chef-workstation" |
| 408 | + Get-ChildItem -Path "C:\opscode\chef-workstation" -Recurse -Depth 1 |
| 409 | + Copy-Item -Path "C:\opscode\chef-workstation" -Destination $ExtractPath -Recurse -Force |
| 410 | + } |
| 411 | + if (Test-Path "C:\opscode\${{ inputs.product }}") { |
| 412 | + Write-Host "Found installation at: C:\opscode\${{ inputs.product }}" |
| 413 | + Get-ChildItem -Path "C:\opscode\${{ inputs.product }}" -Recurse -Depth 1 |
| 414 | + Copy-Item -Path "C:\opscode\${{ inputs.product }}" -Destination $ExtractPath -Recurse -Force |
| 415 | + } |
| 416 | + } else { |
| 417 | + # Extract the package based on its type (assuming .zip for non-Windows platforms) |
| 418 | + Expand-Archive -Path "$env:TEMP\package_downloaded" -DestinationPath $ExtractPath -Force |
| 419 | + Write-Host "Package downloaded and extracted to $ExtractPath" |
| 420 | + } |
373 | 421 |
|
374 | 422 | Get-ChildItem -Path $ExtractPath |
375 | 423 |
|
|
0 commit comments