From 4ca0dd0f9bc92403f9b7194dbd7eab0c2b04db96 Mon Sep 17 00:00:00 2001 From: "Brady Stroud [SSW]" Date: Thu, 13 Feb 2025 16:11:05 +1030 Subject: [PATCH] CI/CD - Fix builds from big content change (#1683) * test * Try fix script * fix 2 * Yeah fix * fix typing * fic more * Clean up * Remove logging step for should_generate_commit_data in workflow * Fix PR builds --- .github/workflows/pr-build.yml | 1 + .github/workflows/template-build.yml | 4 +--- build-scripts/update-rule-history.ps1 | 22 +++++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 43aa7b666..2a74c3c11 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -14,4 +14,5 @@ jobs: with: branch_name: ${{ github.ref }} environment: staging + should_generate_commit_data: false secrets: inherit diff --git a/.github/workflows/template-build.yml b/.github/workflows/template-build.yml index 90dd560e0..b77497e67 100644 --- a/.github/workflows/template-build.yml +++ b/.github/workflows/template-build.yml @@ -13,8 +13,7 @@ on: should_generate_commit_data: type: boolean description: 'Generate commit data for rules history. You might want to skip this on large rules changes.' - required: false - default: true + required: true jobs: get-content-commit-data: @@ -22,7 +21,6 @@ jobs: runs-on: ubuntu-latest environment: ${{ inputs.environment }} steps: - - uses: actions/checkout@v4 name: Checkout SSW.Rules with: diff --git a/build-scripts/update-rule-history.ps1 b/build-scripts/update-rule-history.ps1 index 0cb52c870..b0afd0f3c 100644 --- a/build-scripts/update-rule-history.ps1 +++ b/build-scripts/update-rule-history.ps1 @@ -4,15 +4,18 @@ param ( [string]$UpdateRuleHistoryKey, [string]$UpdateHistorySyncCommitHashKey, [string]$endCommitHash = "HEAD", - [string]$ShouldGenerateHistory = $true + [string]$ShouldGenerateHistoryString = "true" # Accepts string input # Do this if your PR is giant # https://github.com/SSWConsulting/SSW.Rules/issues/1367 ) -if ($ShouldGenerateHistory -eq $false) { - Write-Output "Skipping history generation" -} else { +# Create a new boolean variable from the string input +$IsHistoryGenerationEnabled = [string]::Equals($ShouldGenerateHistoryString, "true", [System.StringComparison]::OrdinalIgnoreCase) + +if ($IsHistoryGenerationEnabled) { Write-Output "Generating history" +} else { + Write-Output "Skipping history generation" } @@ -50,7 +53,8 @@ $historyArray | Foreach-Object { $commitSyncHash = $userDetails[1] } - if ($ShouldGenerateHistory) { + if ($IsHistoryGenerationEnabled) { + Write-Output "Processing commit $userDetails[1]" $lastUpdated = $userDetails[2] $lastUpdatedBy = $userDetails[3] $lastUpdatedByEmail = $userDetails[4] @@ -112,7 +116,7 @@ $historyArray | Foreach-Object { } -if ($ShouldGenerateHistory) { +if ($IsHistoryGenerationEnabled) { #Step 3: UpdateRuleHistory - Send History Patch to AzureFunction $historyFileContents = ConvertTo-Json $historyFileArray $Uri = $AzFunctionBaseUrl + '/api/UpdateRuleHistory' @@ -131,8 +135,8 @@ if(![string]::IsNullOrWhiteSpace($commitSyncHash)) $Result = Invoke-WebRequest -Uri $Uri -Method Post -Body $Body -Headers $Headers } -if ($ShouldGenerateHistory) { - echo $historyFileContents +if ($IsHistoryGenerationEnabled) { + Write-Output $historyFileContents } -echo $commitSyncHash +Write-Output $commitSyncHash