-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from DFE-Digital/feature/fhb-825-database-see…
…ding Feature/fhb 825 database seeding
- Loading branch information
Showing
29 changed files
with
311 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Runs SQL Scripts | ||
description: Runs SQL script specified by the path provided against the database | ||
|
||
inputs: | ||
keyvault_name: | ||
required: true | ||
description: Name of the key vault to get the secret from | ||
keyvault_secret_name: | ||
required: true | ||
description: Name of the secret containing the database connection string | ||
sql_file_path: | ||
required: true | ||
description: Path to the SQL file | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Run SQL Script in PowerShell | ||
shell: pwsh | ||
run: |- | ||
$ConnectionString = az keyvault secret show --name ${{ inputs.keyvault_secret_name }} --vault-name ${{ inputs.keyvault_name }} --query value --output tsv | ||
$Logs = @() | ||
$SqlFile = Get-ChildItem -Path ${{ inputs.sql_file_path }} -File -Filter *.sql | ||
try { | ||
Invoke-Sqlcmd -ConnectionString $ConnectionString -InputFile $SqlFile -ErrorAction 'Stop' | ||
$LogMessage = ($SqlFile.Name + " Executed Successfully.") | ||
} | ||
catch { | ||
$LogMessage = "Error executing $($SqlFile.Name): $_" | ||
throw | ||
} | ||
$Row = [PSCustomObject]@{ | ||
"File" = $SqlFile.Name | ||
"Date" = (Get-Date -UFormat "%d-%m-%Y") | ||
"Log" = $LogMessage | ||
} | ||
$Logs += $Row | ||
Write-Output ($Logs | Format-Table -AutoSize -Wrap | Out-String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.