Skip to content

Commit

Permalink
CI/CD - Fix builds from big content change (#1683)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bradystroud authored Feb 13, 2025
1 parent 539d3f1 commit 4ca0dd0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ jobs:
with:
branch_name: ${{ github.ref }}
environment: staging
should_generate_commit_data: false
secrets: inherit
4 changes: 1 addition & 3 deletions .github/workflows/template-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ 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:
name: Generate commit data
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:

- uses: actions/checkout@v4
name: Checkout SSW.Rules
with:
Expand Down
22 changes: 13 additions & 9 deletions build-scripts/update-rule-history.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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'
Expand All @@ -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

0 comments on commit 4ca0dd0

Please sign in to comment.