Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ on:
- 'bugfix/**'
workflow_dispatch:

env:
OCTOPUS_TENANT_NAME: Internal
OCTOPUS_PROJECT_NAME: Trident - Tenant
OCTOPUS_FEATURE_BRANCH_CHANNEL: Default
OCTOPUS_FEATURE_BRANCH_ENVIRONMENT: Development
OCTOPUS_RELEASE_CHANNEL: Release
OCTOPUS_RELEASE_ENVIRONMENT: Staging
OCTOPUS_SPACE: Default
OCTOPUS_API_KEY: ${{ secrets.OCTOPUSSERVERAPIKEY }}
OCTOPUS_URL: ${{ secrets.OCTOPUSSERVERURL }}

jobs:

build-and-push-application:
Expand All @@ -31,20 +42,34 @@ jobs:
$branchName = (((${env:GITHUB_REF} -replace "refs/heads/", "") -replace "feature/", "") -replace "bugfix/", "") -replace " ", ""
Write-Host "The Branch Name is: $branchName"

$channelName = "${env:OCTOPUS_RELEASE_CHANNEL}"
Write-Host "The channel name is now $channelName"
$environmentName = "${env:OCTOPUS_RELEASE_ENVIRONMENT}"
Write-Host "The environment name is now $environmentName"
$versionNumber = "$($versionPrefix).${env:GITHUB_RUN_NUMBER}"
Write-Host "The version number is now $versionNumber"

if ($branchName -ne "main")
{
Write-Host "The branch is not the main branch, using the feature branch settings instead."

$channelName = "${env:OCTOPUS_FEATURE_BRANCH_CHANNEL}"
Write-Host "The channel name is now $channelName"
$environmentName = "${env:OCTOPUS_FEATURE_BRANCH_ENVIRONMENT}"
Write-Host "The environment name is now $environmentName"
$versionNumber = "$versionNumber-$branchName"
Write-Host "The version number is now $versionNumber"
}
}

Write-Host "Setting the Output Variable OCTOPUS_CHANNEL to $channelName"
Write-Output "OCTOPUS_CHANNEL=$channelName" >> $Env:GITHUB_OUTPUT

Write-Host "Setting the Output Variable VERSION to $versionNumber"
Write-Output "APP_VERSION=$versionNumber" >> $Env:GITHUB_OUTPUT

Write-Host "Setting the Output Variable OCTOPUS_ENVIRONMENT to $environmentName"
Write-Output "OCTOPUS_ENVIRONMENT=$environmentName" >> $Env:GITHUB_OUTPUT

shell: pwsh
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
Expand All @@ -68,4 +93,61 @@ jobs:
- name: build database
working-directory: src/Octopus.Trident.Database.DbUp
run: dotnet publish --output "$GITHUB_WORKSPACE/artifacts/database" -c Release --runtime win-x64 --sc true --p:PublishSingleFile=true --p:PublishTrimmed=true --p:Version=${{ steps.ReleaseNum.outputs.APP_VERSION }}

- name: package website
id: "website_package"
uses: OctopusDeploy/create-zip-package-action@v3
with:
package_id: Trident.Web
version: ${{ steps.ReleaseNum.outputs.APP_VERSION }}
base_path: "artifacts/web"
files: "**/*"
output_folder: packaged

- name: package database
id: "database_package"
uses: OctopusDeploy/create-zip-package-action@v3
with:
package_id: Trident.Database
version: ${{ steps.ReleaseNum.outputs.APP_VERSION }}
base_path: "artifacts/database"
files: "**/*"
output_folder: packaged

- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: assets-for-download
path: packaged

- name: push packages to Octopus
uses: OctopusDeploy/push-package-action@v3
with:
packages: |
packaged/**/*.zip

- name: push build information to Octopus
uses: OctopusDeploy/push-build-information-action@v3
with:
packages: |
Trident.Database
Trident.Web
version: ${{ steps.ReleaseNum.outputs.APP_VERSION }}

- name: create release
uses: OctopusDeploy/create-release-action@v3
with:
project: ${{ env.OCTOPUS_PROJECT_NAME }}
channel: ${{ steps.ReleaseNum.outputs.OCTOPUS_CHANNEL }}
release_number: ${{ steps.ReleaseNum.outputs.APP_VERSION }}
package_version: ${{ steps.ReleaseNum.outputs.APP_VERSION }}

- name: deploy release
uses: OctopusDeploy/deploy-release-tenanted-action@v3
id: "deploy_release"
with:
project: ${{ env.OCTOPUS_PROJECT_NAME }}
release_number: ${{ steps.ReleaseNum.outputs.APP_VERSION }}
environment: ${{ steps.ReleaseNum.outputs.OCTOPUS_ENVIRONMENT }}
tenants: ${{ env.OCTOPUS_TENANT_NAME }}

185 changes: 185 additions & 0 deletions .octopus/deployment_process.ocl
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
step "calculate-deployment-mode" {
name = "Calculate Deployment Mode"

action {
properties = {
Octopus.Action.Template.Id = "ActionTemplates-6"
Octopus.Action.Template.Version = "5"
}
worker_pool = "hosted-windows"
worker_pool_variable = ""
}
}

step "create-database-via-runbook" {
condition = "Variable"
name = "Create Database Via Runbook"
properties = {
Octopus.Step.ConditionVariableExpression = "#{unless Octopus.Deployment.Error}#{Octopus.Action[Calculate Deployment Mode].Output.RunOnDeploy}#{/unless}"
}

action {
properties = {
Octopus.Action.Template.Id = "ActionTemplates-5"
Octopus.Action.Template.Version = "18"
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 = "Trident"
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-4"
Octopus.Action.Template.Version = "3"
}
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"
SelectionMode = "deferred"
}
}
}
}

step "review-database-changes" {
condition = "Variable"
name = "Review Database Changes."
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 the database changes from the artifact attached to this deployment."
Octopus.Action.Manual.ResponsibleTeamIds = "dba,global/octopus-managers"
}
}
}

step "deploy-database-changes" {
condition = "Variable"
name = "Deploy Database 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.WhatIf = "False"
Octopus.Action.Template.Id = "ActionTemplates-4"
Octopus.Action.Template.Version = "3"
}
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"
SelectionMode = "deferred"
}
}
}
}

step "deploy-a-trident-web" {
name = "Deploy a Trident Web"
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-app" {
name = "Verify App"

action {
action_type = "Octopus.Script"
properties = {
Octopus.Action.Script.ScriptBody = "Write-Host \"This application has been verified.\""
Octopus.Action.Script.ScriptSource = "Inline"
Octopus.Action.Script.Syntax = "PowerShell"
OctopusUseBundledTooling = "False"
}
worker_pool = "hosted-windows"
}
}

step "notification" {
condition = "Always"
name = "Notification"

action {
properties = {
Octopus.Action.Template.Id = "ActionTemplates-1"
Octopus.Action.Template.Version = "15"
ssn_Color = "good"
ssn_HookUrl = "#{Notification.Slack.Webhook.Url}"
ssn_IconUrl = "https://octopus.com/content/resources/favicon.png"
ssn_Message = "#{Notification.Body.Text}"
ssn_Title = "#{Notification.Subject.Text}"
ssn_Username = "Octopus Deploy"
}
worker_pool = "hosted-windows"
}
}
7 changes: 7 additions & 0 deletions .octopus/deployment_settings.ocl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
connectivity_policy {
allow_deployments_to_no_targets = true
}

versioning_strategy {
template = "#{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch}"
}
47 changes: 47 additions & 0 deletions .octopus/runbooks/migrated-drafts/configure-sql-server.ocl
Original file line number Diff line number Diff line change
@@ -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 {
type = "Default"
}

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-2"
Octopus.Action.Template.Version = "5"
}
worker_pool = "hosted-windows"
}
}
}
1 change: 1 addition & 0 deletions .octopus/schema_version.ocl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = 10
Loading