Skip to content

Commit

Permalink
Support installation of SQL Express 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
andyundso committed Jul 28, 2024
1 parent a95ae6a commit 81b45f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
version:
- 2017
- 2019
- 2022
exclude:
- force-encryption: "true"
os: ubuntu-24.04
Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ inputs:
default: "false"
sa-password:
description: "The SA password for the SQL instance"
required: true
required: false
default: "bHuZH81%cGC6"
version:
description: "The version of the SQL instance"
required: true
required: false
default: "2022"
runs:
using: "composite"
steps:
Expand Down
15 changes: 13 additions & 2 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param (
[string[]]$Components,
[bool]$ForceEncryption,
[string]$SaPassword,
[ValidateSet("2017", "2019")]
[ValidateSet("2017", "2019", "2022")]
[string]$Version
)

Expand Down Expand Up @@ -101,8 +101,15 @@ forceencryption = 1
$AdditionalContainerConfiguration = "-v /opt/mssql/mssql.conf:/var/opt/mssql/mssql.conf -v /opt/mssql/mssql.pem:/var/opt/mssql/mssql.pem -v /opt/mssql/mssql.key:/var/opt/mssql/mssql.key"
}

if ($Version -Eq "2022") {
$ToolsPath = "/opt/mssql-tools18"
}
else {
$ToolsPath = "/opt/mssql-tools"
}

Write-Output "Starting a Docker Container"
Invoke-Expression "docker run --name=`"sql`" -e `"ACCEPT_EULA=Y`"-e `"SA_PASSWORD=$SaPassword`" -e `"MSSQL_PID=Express`" --health-cmd=`"/opt/mssql-tools/bin/sqlcmd -C -S localhost -U sa -P '$SaPassword' -Q 'SELECT 1' -b -o /dev/null`" --health-start-period=`"10s`" --health-retries=3 --health-interval=`"10s`" -p 1433:1433 $AdditionalContainerConfiguration -d `"mcr.microsoft.com/mssql/server:$Version-latest`""
Invoke-Expression "docker run --name=`"sql`" -e `"ACCEPT_EULA=Y`"-e `"SA_PASSWORD=$SaPassword`" -e `"MSSQL_PID=Express`" --health-cmd=`"$ToolsPath/bin/sqlcmd -C -S localhost -U sa -P '$SaPassword' -Q 'SELECT 1' -b -o /dev/null`" --health-start-period=`"10s`" --health-retries=3 --health-interval=`"10s`" -p 1433:1433 $AdditionalContainerConfiguration -d `"mcr.microsoft.com/mssql/server:$Version-latest`""
Wait-ForContainer
}

Expand All @@ -119,6 +126,10 @@ forceencryption = 1
$DownloadUrl = "https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe"
$MajorVersion = 15
}
"2022" {
$DownloadUrl = "https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/SQLEXPR_x64_ENU.exe"
$MajorVersion = 16
}
}

Invoke-WebRequest $DownloadUrl -OutFile "C:\Downloads\mssql.exe"
Expand Down

0 comments on commit 81b45f9

Please sign in to comment.