Skip to content

Commit

Permalink
Remove debugging DB queries
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkyjac committed Oct 22, 2024
1 parent 15e1050 commit 78ab8d3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ jobs:
-U "sa" `
-P "Pass@12345" `
-Q "RESTORE DATABASE [${{env.DB_NAME}}] FROM DISK='/var/opt/mssql/backup/${{ env.DATABASE_BACKUP_FILENAME }}' WITH MOVE 'XByK_DancingGoat_Shopify' TO '/var/opt/mssql/data/${{env.DB_NAME}}.mdf', MOVE 'XByK_DancingGoat_Shopify_log' TO '/var/opt/mssql/data/${{env.DB_NAME}}_log.ldf'"
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "SELECT KeyValue FROM ${{env.DB_NAME}}.dbo.CMS_SettingsKey WHERE KeyName = 'CMSDBVersion'"
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "SELECT TOP 1 EventTime, EventDescription FROM ${{env.DB_NAME}}.dbo.CMS_EventLog ORDER BY EventTime DESC"
if: endsWith(env.DATABASE_BACKUP_FILENAME, '.bak')

- name: Restore Database .bacpac
Expand All @@ -121,7 +109,7 @@ jobs:
- name: Restore CI Repository
working-directory: "./scripts"
run: |
./Restore-CI.ps1
./UpdateAndRestoreCI.ps1
- name: Publish Application
run: |
Expand All @@ -148,8 +136,6 @@ jobs:
# Run the ASP.NET Core app as a background job
cd ./publish
Start-Job -ScriptBlock { dotnet ./${{ env.PROJECT_NAME }}.dll } -Name ${{ env.PROJECT_NAME }}
Start-Sleep -Seconds 10
Get-Job
Receive-Job -Name ${{ env.PROJECT_NAME }}
cd ../
Expand Down
Binary file modified database/XByK_DancingGoat_Shopify.bak.zip
Binary file not shown.
25 changes: 16 additions & 9 deletions scripts/Restore-CI.ps1 → scripts/UpdateAndRestoreCI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ Import-Module (Resolve-Path Utilities) `
Write-Status `
-Force

$projectPath = Get-WebProjectPath
$repositoryPath = Join-Path $projectPath "App_Data/CIRepository"
$launchProfile = $Env:ASPNETCORE_ENVIRONMENT -eq "CI" ? "EcommerceShopify.WebCI" : "DancingGoat"
$configuration = $Env:ASPNETCORE_ENVIRONMENT -eq "CI" ? "Release" : "Debug"
$dbName = $Env:DB_NAME
function SetCIValue {
param(
[string]$ciValue
)

$turnOffCI = "sqlcmd " + `
$toggleCICommand = "sqlcmd " + `
"-S localhost " + `
"-d $dbName " + `
"-d $Env:DB_NAME " + `
"-U `"sa`" " + `
"-P `"Pass@12345`" " + `
"-Q `"UPDATE CMS_SettingsKey SET KeyValue = N'False' WHERE KeyName = N'CMSEnableCI'`""
"-Q `"UPDATE CMS_SettingsKey SET KeyValue = N'$ciValue' WHERE KeyName = N'CMSEnableCI'`""
Invoke-ExpressionWithException $toggleCICommand
}

$projectPath = Get-WebProjectPath
$repositoryPath = Join-Path $projectPath "App_Data/CIRepository"
$launchProfile = $Env:ASPNETCORE_ENVIRONMENT -eq "CI" ? "EcommerceShopify.WebCI" : "DancingGoat"
$configuration = $Env:ASPNETCORE_ENVIRONMENT -eq "CI" ? "Release" : "Debug"

$updateCommand = "dotnet run " + `
"--launch-profile $launchProfile " + `
Expand All @@ -34,9 +40,10 @@ $restoreCommand = "dotnet run " + `
"--project $projectPath " + `
"--kxp-ci-restore"

Invoke-ExpressionWithException $turnOffCI
SetCIValue 'False'
Invoke-ExpressionWithException $updateCommand
Invoke-ExpressionWithException $restoreCommand
SetCIValue 'True'

Write-Host "`n"
Write-Status 'CI files processed'
Expand Down

0 comments on commit 78ab8d3

Please sign in to comment.