diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd60b02..ba9ee70 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -140,6 +140,7 @@ jobs: channel: ${{ steps.ReleaseNum.outputs.OCTOPUS_CHANNEL }} release_number: ${{ steps.ReleaseNum.outputs.APP_VERSION }} package_version: ${{ steps.ReleaseNum.outputs.APP_VERSION }} + git_ref: ${{ github.ref }} - name: deploy release uses: OctopusDeploy/deploy-release-action@v3 diff --git a/.octopus/deployment_process.ocl b/.octopus/deployment_process.ocl new file mode 100644 index 0000000..0343e01 --- /dev/null +++ b/.octopus/deployment_process.ocl @@ -0,0 +1,196 @@ +step "calculate-deployment-mode" { + name = "Calculate Deployment Mode" + + action { + properties = { + Octopus.Action.RunOnServer = "true" + Octopus.Action.Template.Id = "ActionTemplates-5" + Octopus.Action.Template.Version = "5" + } + worker_pool_variable = "" + } +} + +step "run-configure-sql-server-runbook" { + condition = "Variable" + name = "Run Configure SQL Server Runbook" + properties = { + Octopus.Step.ConditionVariableExpression = "#{unless Octopus.Deployment.Error}#{Octopus.Action[Calculate Deployment Mode].Output.RunOnDeploy}#{/unless}" + } + + action { + properties = { + Octopus.Action.Template.Id = "ActionTemplates-4" + Octopus.Action.Template.Version = "17" + Run.Runbook.Api.Key = "#{Project.Runbook.Api.Key}" + Run.Runbook.AutoApproveManualInterventions = "No" + Run.Runbook.Base.Url = "#{Octopus.Web.ServerUri}" + Run.Runbook.CancelInSeconds = "1800" + Run.Runbook.CustomNotes.Toggle = "False" + Run.Runbook.DateTime = "N/A" + Run.Runbook.Environment.Name = "#{Octopus.Environment.Name}" + Run.Runbook.Machines = "N/A" + Run.Runbook.ManualIntervention.EnvironmentToUse = "#{Octopus.Environment.Name}" + Run.Runbook.Name = "Configure SQL Server" + Run.Runbook.Project.Name = "#{Octopus.Project.Name}" + Run.Runbook.Space.Name = "#{Octopus.Space.Name}" + Run.Runbook.UsePublishedSnapShot = "True" + Run.Runbook.Waitforfinish = "True" + } + worker_pool = "hosted-windows" + } +} + +step "generate-what-if-report" { + condition = "Variable" + name = "Generate What If Report" + properties = { + Octopus.Step.ConditionVariableExpression = "#{unless Octopus.Deployment.Error}#{Octopus.Action[Calculate Deployment Mode].Output.RunOnDeploy}#{/unless}" + } + + action { + properties = { + Database.Deploy.ConnectionString = "#{Project.Connection.String}" + Database.Deploy.Package = "{\"PackageId\":\"Trident.Database\",\"FeedId\":\"octopus-server-built-in\"}" + Database.Deploy.PathToDBUpExe = ".\\Octopus.Trident.Database.DbUp" + Database.Deploy.ReportPath = "#{Project.Database.Report.Path}" + Database.Deploy.WhatIf = "True" + Octopus.Action.Template.Id = "ActionTemplates-2" + Octopus.Action.Template.Version = "1" + } + worker_pool = "hosted-windows" + + packages "Database.Deploy.Package" { + acquisition_location = "Server" + feed = "octopus-server-built-in" + package_id = "Trident.Database" + properties = { + Extract = "True" + PackageParameterName = "Database.Deploy.Package" + Purpose = "" + SelectionMode = "deferred" + } + } + } +} + +step "dba-review-delta-script" { + condition = "Variable" + name = "DBA Review Delta Script" + properties = { + Octopus.Step.ConditionVariableExpression = "#{unless Octopus.Deployment.Error}#{Octopus.Action[Calculate Deployment Mode].Output.RunOnDeploy}#{/unless}" + } + + action { + action_type = "Octopus.Manual" + environments = ["staging"] + properties = { + Octopus.Action.Manual.BlockConcurrentDeployments = "False" + Octopus.Action.Manual.Instructions = "Please review generated script." + Octopus.Action.Manual.ResponsibleTeamIds = "global/octopus-managers" + } + } +} + +step "deploy-db-changes" { + condition = "Variable" + name = "Deploy DB Changes" + properties = { + Octopus.Step.ConditionVariableExpression = "#{unless Octopus.Deployment.Error}#{Octopus.Action[Calculate Deployment Mode].Output.RunOnDeploy}#{/unless}" + } + + action { + properties = { + Database.Deploy.ConnectionString = "#{Project.Connection.String}" + Database.Deploy.Package = "{\"PackageId\":\"Trident.Database\",\"FeedId\":\"octopus-server-built-in\"}" + Database.Deploy.PathToDBUpExe = ".\\Octopus.Trident.Database.DbUp" + Database.Deploy.ReportPath = "#{Project.Database.Report.Path}" + Database.Deploy.WhatIf = "False" + Octopus.Action.Template.Id = "ActionTemplates-2" + Octopus.Action.Template.Version = "1" + } + worker_pool = "hosted-windows" + + packages "Database.Deploy.Package" { + acquisition_location = "Server" + feed = "octopus-server-built-in" + package_id = "Trident.Database" + properties = { + Extract = "True" + PackageParameterName = "Database.Deploy.Package" + Purpose = "" + SelectionMode = "deferred" + } + } + } +} + +step "deploy-trident-web-application" { + name = "Deploy Trident Web Application" + properties = { + Octopus.Action.TargetRoles = "trident-web" + } + + action { + action_type = "Octopus.TentaclePackage" + properties = { + Octopus.Action.EnabledFeatures = "Octopus.Features.JsonConfigurationVariables" + Octopus.Action.Package.DownloadOnTentacle = "False" + Octopus.Action.Package.FeedId = "octopus-server-built-in" + Octopus.Action.Package.JsonConfigurationVariablesTargets = "appSettings.json" + Octopus.Action.Package.PackageId = "Trident.Web" + } + worker_pool_variable = "" + + packages { + acquisition_location = "Server" + feed = "octopus-server-built-in" + package_id = "Trident.Web" + properties = { + SelectionMode = "immediate" + } + } + } +} + +step "verify-application" { + name = "Verify Application" + + action { + action_type = "Octopus.Script" + properties = { + Octopus.Action.Script.ScriptBody = "Write-Highlight \"The app has been successfully verified!\"" + Octopus.Action.Script.ScriptSource = "Inline" + Octopus.Action.Script.Syntax = "PowerShell" + OctopusUseBundledTooling = "False" + } + worker_pool = "hosted-windows" + } +} + +step "notify-team-of-deployment-status" { + condition = "Always" + name = "Notify team of deployment status" + properties = { + Octopus.Action.TargetRoles = "trident-web" + } + + action { + properties = { + Octopus.Action.RunOnServer = "false" + Octopus.Action.Template.Id = "ActionTemplates-1" + Octopus.Action.Template.Version = "2" + PowerAutomatePostAdaptiveCard.BodyColor = "default" + PowerAutomatePostAdaptiveCard.ButtonTitle = "See deployment" + PowerAutomatePostAdaptiveCard.ButtonUrl = "#{Octopus.Web.ServerUri}/app#/#{Octopus.Space.Id}/tasks/#{Octopus.Task.Id}" + PowerAutomatePostAdaptiveCard.HookUrl = "#{Notification.Slack.Webhook.Url}" + PowerAutomatePostAdaptiveCard.RetryCount = "1" + PowerAutomatePostAdaptiveCard.RetryDelay = "100" + PowerAutomatePostAdaptiveCard.RetryPosting = "False" + PowerAutomatePostAdaptiveCard.Timeout = "60" + PowerAutomatePostAdaptiveCard.Title = "#{Notification.Subject.Text}" + PowerAutomatePostAdaptiveCard.TitleColor = "accent" + } + worker_pool_variable = "" + } +} \ No newline at end of file diff --git a/.octopus/deployment_settings.ocl b/.octopus/deployment_settings.ocl new file mode 100644 index 0000000..d5ed81d --- /dev/null +++ b/.octopus/deployment_settings.ocl @@ -0,0 +1,9 @@ +default_guided_failure_mode = "On" + +connectivity_policy { + allow_deployments_to_no_targets = true +} + +versioning_strategy { + template = "#{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch}" +} \ No newline at end of file diff --git a/.octopus/runbooks/configure-sql-server.ocl b/.octopus/runbooks/configure-sql-server.ocl new file mode 100644 index 0000000..ee0c992 --- /dev/null +++ b/.octopus/runbooks/configure-sql-server.ocl @@ -0,0 +1,47 @@ +name = "Configure SQL Server" +default_guided_failure_mode = "EnvironmentDefault" +description = "" + +connectivity_policy { + allow_deployments_to_no_targets = true +} + +run_retention_policy { + quantity_to_keep = 100 +} + +process { + step "install-sql-server" { + name = "Install SQL Server" + + action { + action_type = "Octopus.Script" + properties = { + Octopus.Action.Script.ScriptBody = <<-EOT + Write-Host "Installing SQL Server Localdb" + choco install sqllocaldb -y + EOT + Octopus.Action.Script.ScriptSource = "Inline" + Octopus.Action.Script.Syntax = "PowerShell" + OctopusUseBundledTooling = "False" + } + worker_pool = "hosted-windows" + } + } + + step "sql-create-database-if-not-exists" { + name = "SQL - Create Database If Not Exists" + + action { + properties = { + createCommandTimeout = "30" + createDatabaseName = "#{Project.Database.Name}" + createSqlDatabaseRetryAttempts = "0" + createSqlServer = "#{Project.Database.Server.Name}" + Octopus.Action.Template.Id = "ActionTemplates-3" + Octopus.Action.Template.Version = "5" + } + worker_pool = "hosted-windows" + } + } +} \ No newline at end of file diff --git a/.octopus/schema_version.ocl b/.octopus/schema_version.ocl new file mode 100644 index 0000000..d55ce03 --- /dev/null +++ b/.octopus/schema_version.ocl @@ -0,0 +1 @@ +version = 9 \ No newline at end of file diff --git a/.octopus/variables.ocl b/.octopus/variables.ocl new file mode 100644 index 0000000..ea4e570 --- /dev/null +++ b/.octopus/variables.ocl @@ -0,0 +1,33 @@ +variable "ConnectionStrings:Database" { + value "#{Project.Connection.String}" {} +} + +variable "Project.Connection.String" { + value "Server=#{Project.Database.Server.Name};Integrated Security=true;Database=#{Project.Database.Name}" {} +} + +variable "Project.Database.Name" { + value "Trident" { + environment = ["production"] + } + + value "Trident_Development" { + environment = ["development"] + } + + value "Trident_Staging" { + environment = ["staging"] + } + + value "Trident_Test" { + environment = ["test"] + } +} + +variable "Project.Database.Report.Path" { + value "C:\\DatabaseReports\\\\#{Octopus.Environment.Name}" {} +} + +variable "Project.Database.Server.Name" { + value "(localdb)\\MSSQLLocalDB" {} +} \ No newline at end of file