Skip to content

Commit 2b8114f

Browse files
Adding trust certificate flag
1 parent ec54081 commit 2b8114f

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ A GitHub Action that takes in a list of dependency scripts for a database, downl
1515

1616
## Inputs
1717

18-
| Parameter | Is Required | Default | Description |
19-
| ------------------------- | ----------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20-
| `db-server-name` | true | N/A | The server where the dependency files will be run. |
21-
| `db-name` | true | N/A | The name of the database where the dependency files will run. |
22-
| `dependency-list` | true | N/A | A json string containing a list of objects with the name of the dependency package, the version,the url where the package is stored, and optionally the auth token needed to download the package. |
23-
| `use-integrated-security` | true | false | Use domain integrated security. If false, a db-username and db-password should be specified. If true, those parameters will be ignored if specified. |
24-
| `db-username` | false | N/A | The username to use to login to the database. This is required if use-integrated-security is false, otherwise it's optional and will be ignored. |
25-
| `db-password` | false | N/A | The password for the user logging in to the database. This is required if use-integrated-security is false, otherwise it's optional and will be ignored. |
18+
| Parameter | Is Required | Default | Description |
19+
| -------------------------- | ----------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20+
| `db-server-name` | true | N/A | The server where the dependency files will be run. |
21+
| `db-name` | true | N/A | The name of the database where the dependency files will run. |
22+
| `dependency-list` | true | N/A | A json string containing a list of objects with the name of the dependency package, the version,the url where the package is stored, and optionally the auth token needed to download the package. |
23+
| `use-integrated-security` | true | false | Use domain integrated security. If false, a db-username and db-password should be specified. If true, those parameters will be ignored if specified. |
24+
| `db-username` | false | N/A | The username to use to login to the database. This is required if use-integrated-security is false, otherwise it's optional and will be ignored. |
25+
| `db-password` | false | N/A | The password for the user logging in to the database. This is required if use-integrated-security is false, otherwise it's optional and will be ignored. |
26+
| `trust-server-certificate` | false | false | A boolean that controls whether or not to validate the SQL Server TLS certificate. |
2627

2728
The `dependency-list` should be an array of objects with the following properties:
2829

@@ -59,6 +60,7 @@ jobs:
5960
with:
6061
db-server-name: 'localhost,1433'
6162
db-name: 'LocalDb'
63+
trust-server-certificate: 'true'
6264
dependency-list: '[{"version":"1.0.0","packageName":"dbo.Something","nugetUrl":"https://nuget.pkg.github.com/my-org/download/Something/1.0.0/dbo.Something.1.0.0.nupkg","authToken":"ghp_dkfsjakldafl"},{"version":"1.2.0","packageName":"dbo.SomeOtherThing","nugetUrl":"https://nuget.pkg.github.com/my-org/download/SomeOtherThing/1.2.0/dbo.SomeOtherThing1.2.0.nupkg","authToken":"ghp_dkfsjakldafl"}]'
6365
```
6466

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
db-password:
2323
description: The password for the user logging in to the database. This is required if use-integrated-security is false, otherwise it's optional and will be ignored.
2424
required: false
25+
trust-server-certificate:
26+
description: A boolean that controls whether or not to validate the SQL Server TLS certificate.
27+
required: false
28+
default: 'false'
2529

2630
runs:
2731
using: 'composite'
@@ -42,4 +46,5 @@ runs:
4246
-dbName "${{ inputs.db-name }}" `
4347
-useIntegratedSecurity:$${{ inputs.use-integrated-security }} `
4448
-username "${{ inputs.db-username }}" `
45-
-password $securePassword
49+
-password $securePassword `
50+
-trustServerCertificate:$${{ inputs.trust-server-certificate }}

src/run-db-dependencies.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ param (
33
[string]$dbName,
44
[switch]$useIntegratedSecurity = $false,
55
[string]$username,
6-
[securestring]$password
6+
[securestring]$password,
7+
[switch]$trustServerCertificate
78
)
89

910
Write-Host "Running database dependency scripts"
@@ -21,6 +22,10 @@ $sqlCmdParams = @(
2122
"-Verbose"
2223
)
2324

25+
if ($trustServerCertificate) {
26+
$sqlCmdParams += "-TrustServerCertificate"
27+
}
28+
2429
$temp2 = [string]::Join(" ", $sqlCmdParams)
2530
$temp = @("Invoke-Sqlcmd $temp2")
2631

0 commit comments

Comments
 (0)