diff --git a/Tailspin.SpaceGame.Web/Controllers/HomeController.cs b/Tailspin.SpaceGame.Web/Controllers/HomeController.cs index fd63497f3..d6d5a53f5 100644 --- a/Tailspin.SpaceGame.Web/Controllers/HomeController.cs +++ b/Tailspin.SpaceGame.Web/Controllers/HomeController.cs @@ -134,4 +134,4 @@ public IActionResult Error() return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } -} +} \ No newline at end of file diff --git a/Tailspin.SpaceGame.Web/Startup.cs b/Tailspin.SpaceGame.Web/Startup.cs index 659297b46..fe0643791 100644 --- a/Tailspin.SpaceGame.Web/Startup.cs +++ b/Tailspin.SpaceGame.Web/Startup.cs @@ -67,4 +67,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) }); } } -} +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..ba5a8198e --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,147 @@ +trigger: +- '*' + +variables: + buildConfiguration: 'Release' + +stages: +- stage: 'Build' + displayName: 'Build the web application' + jobs: + - job: 'Build' + displayName: 'Build job' + pool: + vmImage: 'ubuntu-20.04' + demands: + - npm + + variables: + wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot' + dotnetSdkVersion: '6.x' + + steps: + - task: UseDotNet@2 + displayName: 'Use .NET SDK $(dotnetSdkVersion)' + inputs: + version: '$(dotnetSdkVersion)' + + - task: Npm@1 + displayName: 'Run npm install' + inputs: + verbose: false + + - script: './node_modules/.bin/node-sass $(wwwrootDir) --output $(wwwrootDir)' + displayName: 'Compile Sass assets' + + - task: gulp@1 + displayName: 'Run gulp tasks' + + - script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt' + displayName: 'Write build info' + workingDirectory: $(wwwrootDir) + + - task: DotNetCoreCLI@2 + displayName: 'Restore project dependencies' + inputs: + command: 'restore' + projects: '**/*.csproj' + + - task: DotNetCoreCLI@2 + displayName: 'Build the project - $(buildConfiguration)' + inputs: + command: 'build' + arguments: '--no-restore --configuration $(buildConfiguration)' + projects: '**/*.csproj' + + - task: DotNetCoreCLI@2 + displayName: 'Publish the project - $(buildConfiguration)' + inputs: + command: 'publish' + projects: '**/*.csproj' + publishWebProjects: false + arguments: '--no-build --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)' + zipAfterPublish: true + + - publish: '$(Build.ArtifactStagingDirectory)' + artifact: drop + +- stage: 'Dev' + displayName: 'Deploy to the dev environment' + dependsOn: Build + jobs: + - deployment: Deploy + pool: + vmImage: 'ubuntu-20.04' + environment: dev + variables: + - group: Release + strategy: + runOnce: + deploy: + steps: + - download: current + artifact: drop + - task: AzureWebApp@1 + displayName: 'Azure App Service Deploy: website' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + appName: '$(WebAppNameDev)' + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' + +- stage: 'Test' + displayName: 'Deploy to the test environment' + dependsOn: Dev + jobs: + - deployment: Deploy + pool: + vmImage: 'ubuntu-20.04' + environment: test + variables: + - group: 'Release' + strategy: + runOnce: + deploy: + steps: + - download: current + artifact: drop + - task: AzureWebApp@1 + displayName: 'Azure App Service Deploy: website' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + appName: '$(WebAppNameTest)' + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' + +- stage: 'Staging' + displayName: 'Deploy to the staging environment' + dependsOn: Test + jobs: + - deployment: Deploy + pool: + vmImage: 'ubuntu-20.04' + environment: staging + variables: + - group: 'Release' + strategy: + runOnce: + deploy: + steps: + - download: current + artifact: drop + - task: AzureWebApp@1 + displayName: 'Azure App Service Deploy: website' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + deployToSlotOrASE: 'true' + resourceGroupName: 'tailspin-space-game-rg' + slotName: 'swap' + appName: '$(WebAppNameStaging)' + package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip' + - task: AzureAppServiceManage@0 + displayName: 'Swap deployment slots' + inputs: + azureSubscription: 'Resource Manager - Tailspin - Space Game' + resourceGroupName: 'tailspin-space-game-rg' + webAppName: '$(WebAppNameStaging)' + sourceSlot: 'swap' + targetSlot: 'production' + action: 'Swap Slots' \ No newline at end of file