Skip to content

Commit

Permalink
Added stage/job/step YAML templates for YAML release pipelines +semve…
Browse files Browse the repository at this point in the history
…r: minor (#144)

* initial building blocks

* Changed path for create resource group task

* Removed path for create resource group

* added config schema path reference

* removed environment in deployment name

* Update app-deploy.yml

* Update app-deploy.yml

* Testing App name for parallel jobs in a stage

* added app-deploy.yml step template

* testing depends on

* lets go

* using parameters json

* clean workspace when deploying arm templte

* added generate parameters file to arm-deploy.yml template

* use environment variables test

* environment test

* inline

* test resource repositores

* remove repository resource

* fixed

* checkout tests

* removed

* import script attempt without checkout

* subscription level arm template deployment

* add AzureServiceConnection parameter

* parameter name change

* parameter changeees

* tests

* hardcode attempt

* revert the hard code

* remove uneeded download github releas task

* re-added checkout

* added placeholder template

* placeholder

* added github release creation in yaml

* added versioning section in readme

* remove master condition for testing

* added prerelease

* hard coded tag value for test

* test

* try another service connection

* temp service connection

* undid changes - confirmed service connection error

* parameterized location

* add versioning stage

* removed pre release

* updated display name for arm template deployment

Co-authored-by: Mohamad Adam <[email protected]>
  • Loading branch information
adam230594 and Mohamad Adam authored Oct 7, 2020
1 parent 4e2bac5 commit 153d422
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 1 deletion.
1 change: 1 addition & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mode: Mainline
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
2. [Branching](#Branching)
3. [Resource naming and parameter metadata description properties](#Resource-naming-and-parameter-metadata-description-properties)
4. [Property name formatting](#Property-name-formatting)
5. [GitHub Releases and Versioning](#GitHub-Releases-and-Versioning)

### Usage

Expand Down Expand Up @@ -122,4 +123,29 @@ The convention of property name formatting, as used in the examples above:
1. Parameters: camelCase (matching the release pipeline override template parameters)
2. Variables: camelCase
3. Resource Deployments: lowercase-with-hyphens
4. Outputs: PascalCase (matching the release pipeline variables)
4. Outputs: PascalCase (matching the release pipeline variables)

## GitHub Releases and Versioning

This section provides an overview of the following:

| Section Header | Description |
| - | - |
| GitHub Releases | This section provides an overview of the das-platform-building-blocks repository release, how to approve a release to GitHub and how to use the Azure DevOps GitHub Release Task within a release pipeline. |
| Release Versioning | This section provides an overview of how to ensure a consistent release versioning policy is used, and GitHub releases are appropriately incremented. |

### GitHub Releases

The das-platform-building-blocks repository is published as a release on GitHub.com. Releases provide a list of changes made to a specific release as well as links to the assets available. Using GitHub releases enables the use of the Azure DevOps GitHub Release Task so that the templates in das-platform-building-blocks can be consumed within Azure Pipeline deployments.

### Release Versioning

To ensure a consistent release versioning policy the following can be used as a reference:

| Increment Type | When to use | How to use |
| -- | -- | -- |
| Major | Breaking changes to scripts | Add `+semver: major` to pull request title. |
| Minor | Addition of new scripts | Add `+semver: minor` to pull request title. |
| Patch | Non-breaking changes to existing scripts | Automatically incremented for every merge if a major or minor is not defined. |

[GitVersion](https://gitversion.readthedocs.io/en/latest/) is used to achieve release versioning. Read more about [Version Incrementing](https://gitversion.readthedocs.io/en/latest/more-info/version-increments/).
1 change: 1 addition & 0 deletions azure-pipelines-templates/build/job/job-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# placeholder file - delete this file when adding first template to this folder
1 change: 1 addition & 0 deletions azure-pipelines-templates/build/stage/stage-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# placeholder file - delete this file when adding first template to this folder
27 changes: 27 additions & 0 deletions azure-pipelines-templates/build/step/app-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
steps:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: 'src/**/*.csproj'
noCache: true

- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: 'src/**/*.csproj'
arguments: '--configuration $(buildConfiguration) --no-restore'

- task: DotNetCoreCLI@2
displayName: 'Unit Tests'
inputs:
command: test
projects: '**/*.UnitTests.csproj'
arguments: '--configuration $(buildConfiguration) --no-build'

- task: DotNetCoreCLI@2
displayName: 'Acceptance Tests'
inputs:
command: test
projects: '**/*.AcceptanceTests.csproj'
arguments: '--configuration $(buildConfiguration) --no-build'
12 changes: 12 additions & 0 deletions azure-pipelines-templates/build/step/dependency-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
steps:
- task: esfadevops.DependencyCheck.custom-dependency-check.DependencyCheck@2
displayName: 'Dependency Check'
inputs:
enableVulnerabilityFilesMaintenance: false
logAnalyticsWorkspaceId: '$(LogAnalyticsWorkspaceId)'
logAnalyticsWorkspaceKey: '$(LogAnalyticsWorkspaceKey)'
enableSelfHostedVulnerabilityFiles: true
readStorageAccountContainerSasUri: '$(DependencyCheckSasUri)'
excludedScanPathPatterns: '$(DependencyCheckExcludedScanPathPatterns)'
severityThreshold: '$(DependencyCheckSeverityThreshold)'
dependencyCheckDashboardUrl: '$(DependencyCheckDashboardUrl)'
54 changes: 54 additions & 0 deletions azure-pipelines-templates/deploy/job/arm-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
parameters:
ServiceConnection: ''
SubscriptionId: ''
Location: ''
Environment: ''
TemplatePath: ''
ParametersPath: ''
ConfigSchemaPath: ''
TemplateSecrets: {}

jobs:
- deployment: DeployInfrastructure
pool:
name: DAS - Continuous Deployment
environment: ${{ parameters.Environment }}
workspace:
clean: all
strategy:
runOnce:
deploy:
steps:
- checkout: das-platform-automation
- task: PowerShell@2
displayName: Generate Parameters File
inputs:
filePath: Infrastructure-Scripts/New-ParametersFile.ps1
arguments: >
-TemplateFilePath ${{ parameters.TemplatePath }}
-ParametersFilePath ${{ parameters.ParametersPath }}
pwsh: true
env: ${{ parameters.TemplateSecrets }}

- task: AzureResourceManagerTemplateDeployment@3
displayName: Azure Subscription Deployment - Create/Tag resource group and deploy resources
inputs:
deploymentScope: Subscription
ConnectedServiceName: ${{ parameters.ServiceConnection }}
subscriptionId: ${{ parameters.SubscriptionId }}
location: ${{ parameters.Location }}
csmFile: ${{ parameters.TemplatePath }}
csmParametersFile: ${{ parameters.ParametersPath }}
deploymentOutputs: ARMOutputs

- task: esfadevops.ARMTemplateOutputs.custom-build-task.ARMTemplateOutputs@0
displayName: Convert ARM Template Outputs to Variables
inputs:
ARMOutputs: $(ARMOutputs)

- template: ../step/generate-config.yml
parameters:
ServiceConnection: ${{ parameters.ServiceConnection }}
SourcePath: ${{ parameters.ConfigSchemaPath }}
TargetFileName: '*.schema.json'
TableName: Configuration
1 change: 1 addition & 0 deletions azure-pipelines-templates/deploy/stage/stage-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# placeholder file - delete this file when adding first template to this folder
57 changes: 57 additions & 0 deletions azure-pipelines-templates/deploy/step/app-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
parameters:
ServiceConnection: ''
AppServiceName: ''
DeploymentPackagePath: ''

steps:
- task: AzureRmWebAppDeployment@3
displayName: Deploy Staging Slot - ${{ parameters.AppServiceName }}
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
appType: webApp
WebAppName: ${{ parameters.AppServiceName }}
DeployToSlotFlag: true
ResourceGroupName: $(ResourceGroupName)
SlotName: staging
Package: ${{ parameters.DeploymentPackagePath }}
UseWebDeploy: true
RemoveAdditionalFilesFlag: true

- task: AzureAppServiceManage@0
displayName: Start Staging Slot - ${{ parameters.AppServiceName }}
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
Action: Start Azure App Service
WebAppName: ${{ parameters.AppServiceName }}
ResourceGroupName: $(ResourceGroupName)
SpecifySlotOrASE: true
Slot: staging

- task: AzureAppServiceManage@0
displayName: Start Swap Slots - ${{ parameters.AppServiceName }}
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
Action: Start Swap With Preview
WebAppName: ${{ parameters.AppServiceName }}
ResourceGroupName: $(ResourceGroupName)
SourceSlot: staging

- task: AzureAppServiceManage@0
displayName: Complete Swap Slot
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
Action: Complete Swap
WebAppName: ${{ parameters.AppServiceName }}
ResourceGroupName: $(ResourceGroupName)
SourceSlot: staging

- task: AzureAppServiceManage@0
displayName: Stop Staging Slot - ${{ parameters.AppServiceName }}
condition: always()
inputs:
azureSubscription: ${{ parameters.ServiceConnection }}
Action: Stop Azure App Service
WebAppName: ${{ parameters.AppServiceName }}
SpecifySlotOrASE: true
ResourceGroupName: $(ResourceGroupName)
Slot: staging
15 changes: 15 additions & 0 deletions azure-pipelines-templates/deploy/step/generate-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
ServiceConnection: ''
SourcePath: ''
TargetFileName: ''
TableName: ''

steps:
- task: esfadevops.GenerateEnvironmentConfiguration.custom-build-task.GenerateEnvironmentConfiguration@3
displayName: 'Generate Configuration'
inputs:
ServiceConnectionName: ${{ parameters.ServiceConnection }}
SourcePath: ${{ parameters.SourcePath }}
TargetFilename: ${{ parameters.TargetFileName }}
StorageAccountName: '$(ConfigurationStorageAccountName)'
TableName: ${{ parameters.TableName }}
47 changes: 47 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
trigger:
batch: true
branches:
include:
- "master"

pr: none

stages:
- stage: Versioning
dependsOn: []
jobs:
- job: GitVersion
displayName: Version
pool:
name: DAS - Continuous Integration
steps:
- task: gittools.gitversion-preview.gitversion-task.GitVersion@5
displayName: GitVersion
inputs:
configFilePath: GitVersion.yml

- stage: Release
dependsOn: Versioning
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
jobs:
- deployment: GitHubRelease
displayName: Create Release in GitHub
pool:
name: DAS - Continuous Deployment
environment: GitHub
strategy:
runOnce:
deploy:
steps:
- task: GitHubRelease@0
inputs:
gitHubConnection: SFA
repositoryName: $(Build.Repository.Name)
action: create
target: $(Build.SourceVersion)
tagSource: manual
tag: $(Build.BuildNumber)
addChangeLog: true
assets: |
$(Build.ArtifactStagingDirectory)/**/*.yml
$(Build.ArtifactStagingDirectory)/**/*.json

0 comments on commit 153d422

Please sign in to comment.