Skip to content

Commit

Permalink
SQL Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
credfeto committed Sep 16, 2024
1 parent fd17a7f commit 32ff8d1
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 52 deletions.
32 changes: 32 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ inputs:
description: 'Whether to create a release in github'
required: true

# DATABASE
SQL_SERVER:
description: 'SQL Server to connect to'
required: false
SQL_DB:
description: 'Database to deploy to'
required: false
SQL_USER:
description: 'User to connect to the database as'
required: false
SQL_PASSWORD:
description: 'Password for SQL_USER'
required: false

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -335,6 +349,7 @@ runs:
PRODUCTION_BUILD: ${{inputs.PRODUCTION_BUILD}}
BUILD_VERSION: ${{env.BUILD_VERSION}}
BUILD_SQL: ${{steps.check_files.outputs.SQL_EXIST}}
DB_FOLDER: ${{github.workspace}}/db
NUGET_PACK: ${{inputs.NUGET_PACK}}
NUGET_FEED: ${{inputs.NUGET_FEED}}
NUGET_SYMBOL_FEED: ${{inputs.NUGET_SYMBOL_FEED}}
Expand Down Expand Up @@ -405,6 +420,23 @@ runs:
CONTAINER_SOURCE: ${{github.workspace}}/server-dist/linux-arm64
CONTAINER_PLATFORM: linux/arm64

- name: "Dotnet: SQL Deploy"
if: |-
steps.check_files.outputs.CSPROJ_EXIST == 'true' &&
steps.check_files.outputs.SLN_EXIST == 'true' &&
steps.check_files.outputs.SQL_EXIST == 'true' &&
inputs.CLOUD_FORMATION_DEPLOY == 'true' &&
inputs.DOCKER_APP_NAME != '' &&
env.DEPLOY == 'true'
uses: ./.github/actions/database-deploy-deploy
with:
BUILD_VERSION: ${{env.BUILD_VERSION}}
SQL_SERVER: ${{inputs.SQL_SERVER}}
SQL_DB: ${{inputs.SQL_DB}}
SQL_USER: ${{inputs.SQL_USER}}
SQL_PASSWORD: ${{inputs.SQL_PASSWORD}}
DB_FOLDER: ${{github.workspace}}/db

- name: "Dotnet: Cloudformation Deploy"
if: |-
steps.check_files.outputs.CSPROJ_EXIST == 'true' &&
Expand Down
45 changes: 0 additions & 45 deletions .github/actions/database-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,51 +29,6 @@ runs:
shell: bash
run: docker pull redgate/sqlcompare:latest

- name: "Build SQL change"
shell: bash
run: |
docker run \
"-v$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" \
--net=host \
--rm redgate/sqlcompare:latest \
/IAgreeToTheEULA \
/filter:"$DB_FILTER" \
/options:CaseSensitiveObjectDefinition,ConsiderNextFilegroupInPartitionSchemes,DecryptPost2kEncryptedObjects,DoNotOutputCommentHeader,ForceColumnOrder,IgnoreCertificatesAndCryptoKeys,IgnoreDatabaseAndServerName,IgnoreUserProperties,IgnoreUsersPermissionsAndRoleMemberships,IgnoreWhiteSpace,IgnoreWithElementOrder,IncludeDependencies,NoDeploymentLogging,ThrowOnFileParseFailed,UseCompatibilityLevel \
/transactionIsolationLevel:SERIALIZABLE \
/include:staticData \
/scriptFile:"$DB_OUTPUT" \
/scripts1:"$DB_SOURCE" \
/showWarnings \
/include:Identical \
/report:"$DB_REPORT" \
/reportType:Xml \
/force \
/OutputWidth:1024 \
/empty2 \
/verbose
env:
DB_SOURCE: ${{inputs.DB_FOLDER}}
DB_OUTPUT: ${{github.workspace}}/update.test.sql
DB_LOG: ${{github.workspace}}/update.log
DB_REPORT: ${{github.workspace}}/update.xml
DB_FILTER: ${{inputs.DB_FOLDER}}/Filter.scpf
DOCKER_CONTENT_TRUST: 0

- name: "Run TSQL Lint"
shell: bash
run: dotnet tsqllint "${{inputs.DB_FOLDER}}"
env:
DOTNET_ROOT: "${{github.workspace}}/.dotnet/${{github.sha}}-${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}"
DOTNET_INSTALL_DIR: "${{github.workspace}}/.dotnet/${{github.sha}}-${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}"
DOTNET_MULTILEVEL_LOOKUP: "false"
DOTNET_NOLOGO: "true"
DOTNET_PRINT_TELEMETRY_MESSAGE: "false"
DOTNET_JitCollect64BitCounts: "1"
DOTNET_ReadyToRun: "0"
DOTNET_TC_QuickJitForLoops: "1"
DOTNET_TC_CallCountingDelayMs: "0"
DOTNET_TieredPGO: "1"
MSBUILDTERMINALLOGGER: "auto"

- name: "Build SQL Diff change"
shell: bash
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/dotnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ inputs:
BUILD_SQL:
description: 'Whether to build SQL DB'
required: true
DB_FOLDER:
description: 'Folder where SQL Files live'
required: false

# GENERAL
GITHUB_TOKEN:
Expand Down Expand Up @@ -144,6 +147,7 @@ runs:
uses: ./.github/actions/sql
with:
BUILD_VERSION: ${{inputs.BUILD_VERSION}}
DB_FOLDER: ${{inputs.DB_FOLDER}}
OCTOPUS_DEPLOY_PACKAGE: ${{inputs.OCTOPUS_DEPLOY_PACKAGE}}
OCTOPUS_DEPLOY_PACKAGE_ZIP: ${{inputs.OCTOPUS_DEPLOY_PACKAGE_ZIP}}

Expand Down
38 changes: 31 additions & 7 deletions .github/actions/sql/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
description: 'Package (root) to deploy when zipped'
required: false

DB_FOLDER:
description: 'Folder where SQL Files live'
required: true

runs:
using: "composite"
steps:
Expand All @@ -27,7 +31,7 @@ runs:

- name: "SQL: Lint SQL Files"
shell: bash
run: dotnet tsqllint "${{github.workspace}}/db"
run: dotnet tsqllint "${{inputs.DB_FOLDER}}"
env:
DOTNET_ROOT: "${{github.workspace}}/.dotnet/${{github.sha}}-${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}"
DOTNET_INSTALL_DIR: "${{github.workspace}}/.dotnet/${{github.sha}}-${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}"
Expand All @@ -45,18 +49,38 @@ runs:
shell: bash
run: docker pull redgate/sqlcompare:latest

- name: "SQL: Build SQL change"
- name: "Build SQL change"
shell: bash
run: docker run "-v$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --net=host --rm redgate/sqlcompare:latest /IAgreeToTheEULA /filter:"$DB_FILTER" /options:ConsiderNextFilegroupInPartitionSchemes,DecryptPost2kEncryptedObjects,DoNotOutputCommentHeader,ForceColumnOrder,IgnoreCertificatesAndCryptoKeys,IgnoreDatabaseAndServerName,IgnoreUserProperties,IgnoreUsersPermissionsAndRoleMemberships,IgnoreWhiteSpace,IgnoreWithElementOrder,IncludeDependencies,NoDeploymentLogging,ThrowOnFileParseFailed,UseCompatibilityLevel /transactionIsolationLevel:SERIALIZABLE /include:staticData /scriptFile:"$DB_OUTPUT" /scripts1:"$DB_SOURCE" /showWarnings /include:Identical /report:"$DB_REPORT" /reportType:Xml /force /OutputWidth:1024 /out:"$DB_LOG" /empty2
run: |
docker run \
"-v$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" \
--net=host \
--rm redgate/sqlcompare:latest \
/IAgreeToTheEULA \
/filter:"$DB_FILTER" \
/options:CaseSensitiveObjectDefinition,ConsiderNextFilegroupInPartitionSchemes,DecryptPost2kEncryptedObjects,DoNotOutputCommentHeader,ForceColumnOrder,IgnoreCertificatesAndCryptoKeys,IgnoreDatabaseAndServerName,IgnoreUserProperties,IgnoreUsersPermissionsAndRoleMemberships,IgnoreWhiteSpace,IgnoreWithElementOrder,IncludeDependencies,NoDeploymentLogging,ThrowOnFileParseFailed,UseCompatibilityLevel \
/transactionIsolationLevel:SERIALIZABLE \
/include:staticData \
/scriptFile:"$DB_OUTPUT" \
/scripts1:"$DB_SOURCE" \
/showWarnings \
/include:Identical \
/report:"$DB_REPORT" \
/reportType:Xml \
/force \
/OutputWidth:1024 \
/empty2 \
/verbose
env:
DB_SOURCE: ${{github.workspace}}/db
DB_OUTPUT: ${{github.workspace}}/update.sql
DB_SOURCE: ${{inputs.DB_FOLDER}}
DB_OUTPUT: ${{github.workspace}}/update.test.sql
DB_LOG: ${{github.workspace}}/update.log
DB_REPORT: ${{github.workspace}}/update.xml
DB_FILTER: ${{github.workspace}}/db/Filter.scpf
DB_FILTER: ${{inputs.DB_FOLDER}}/Filter.scpf
DOCKER_CONTENT_TRUST: 0

- name: "SQL: Zip DB for Octopus"
working-directory: ${{github.workspace}}/db
working-directory: ${{inputs.DB_FOLDER}}
shell: bash
run: |
mkdir -p ../package/db/state
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build-and-publish-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ jobs:
API_PREFIX: ${{vars.API_PREFIX}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}}
SQL_SERVER: ${{vars.SQL_SERVER}}
SQL_DB: ${{vars.SQL_DB}}
SQL_USER: ${{vars.SQL_USER}}
SQL_PASSWORD: ${{secrets.SQL_PASSWORD}}
CREATE_RELEASE: false

- name: "Build and deploy"
Expand Down Expand Up @@ -151,6 +155,10 @@ jobs:
API_PREFIX: ${{vars.API_PREFIX}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}}
SQL_SERVER: ${{vars.SQL_SERVER}}
SQL_DB: ${{vars.SQL_DB}}
SQL_USER: ${{vars.SQL_USER}}
SQL_PASSWORD: ${{secrets.SQL_PASSWORD}}
CREATE_RELEASE: false

- name: "Build Version"
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build-and-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ jobs:
API_PREFIX: ${{vars.API_PREFIX}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}}
SQL_SERVER: ${{vars.SQL_SERVER}}
SQL_DB: ${{vars.SQL_DB}}
SQL_USER: ${{vars.SQL_USER}}
SQL_PASSWORD: ${{secrets.SQL_PASSWORD}}
CREATE_RELEASE: true

- name: "Build and deploy"
Expand Down Expand Up @@ -142,6 +146,10 @@ jobs:
API_PREFIX: ${{vars.API_PREFIX}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}}
SQL_SERVER: ${{vars.SQL_SERVER}}
SQL_DB: ${{vars.SQL_DB}}
SQL_USER: ${{vars.SQL_USER}}
SQL_PASSWORD: ${{secrets.SQL_PASSWORD}}
CREATE_RELEASE: true

- name: "Build Version"
Expand Down

0 comments on commit 32ff8d1

Please sign in to comment.