Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(summary): Create Summary api deployment pipeline #678

Merged
merged 65 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e3cb426
Init deployment yml file
Jonathanio123 Aug 2, 2024
76525cf
Trigger pipeline
Jonathanio123 Aug 2, 2024
0f5d3b5
Updated summary api deployment-test-env.yml
Jonathanio123 Aug 2, 2024
401870c
Change devops environments to match the fusion resources envs instead
Jonathanio123 Aug 5, 2024
b5a8a53
update image name
Jonathanio123 Aug 6, 2024
9ee19db
renamed wrong pipeline
Jonathanio123 Aug 6, 2024
6c08c5e
update image repo
Jonathanio123 Aug 7, 2024
0c3ead4
target to publish
Jonathanio123 Aug 7, 2024
f60e925
target to final
Jonathanio123 Aug 7, 2024
4ffea89
revert target to publish
Jonathanio123 Aug 7, 2024
994cca0
Revert "revert target to publish"
Jonathanio123 Aug 8, 2024
07dbefe
Use windows agnet and removed UseAppHost from dockerfile
Jonathanio123 Aug 8, 2024
9e3a213
Use ubuntu agent
Jonathanio123 Aug 8, 2024
ac6b538
List ArtifactStagingDirectory
Jonathanio123 Aug 8, 2024
cc06883
Testing
Jonathanio123 Aug 8, 2024
55af221
Testing
Jonathanio123 Aug 8, 2024
e572b84
Testing
Jonathanio123 Aug 8, 2024
9a72043
Testing
Jonathanio123 Aug 8, 2024
2e4918e
Testing
Jonathanio123 Aug 8, 2024
9b18ce6
Testing resources
Jonathanio123 Aug 8, 2024
1551c97
testing
Jonathanio123 Aug 8, 2024
1477e89
COPY --from=publish /migrations .
Jonathanio123 Aug 8, 2024
4cbf44f
ef tools test
Jonathanio123 Aug 8, 2024
c98a5ee
Use windows agent
Jonathanio123 Aug 9, 2024
c78c68c
Revert "Use windows agent"
Jonathanio123 Aug 9, 2024
cf11c48
Azurepwsh@5
Jonathanio123 Aug 9, 2024
0019398
Azurepwsh@5 for templates
Jonathanio123 Aug 9, 2024
a7ebaf1
Azurepwsh@5 for templates
Jonathanio123 Aug 9, 2024
f3e8776
Updated sql db target tag
Jonathanio123 Aug 9, 2024
38c09dc
TMP removed sql migration
Jonathanio123 Aug 9, 2024
adcfe61
Added sql exec to steps
Jonathanio123 Aug 9, 2024
ced1951
replaced tab with spaces
Jonathanio123 Aug 9, 2024
c0987e4
Changed env
Jonathanio123 Aug 9, 2024
f8266d8
env typo
Jonathanio123 Aug 9, 2024
241544f
env fusion-resources-app-ci
Jonathanio123 Aug 12, 2024
1869cfb
Updated healthcehck endpoint
Jonathanio123 Aug 12, 2024
5731512
Updated service selector
Jonathanio123 Aug 12, 2024
3aadcbf
Add real db health check
Jonathanio123 Aug 12, 2024
3e7fc80
Revert "Add real db health check"
Jonathanio123 Aug 16, 2024
e0fc9f1
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 16, 2024
d08868e
Updated summary api pipeline to match updated structure
Jonathanio123 Aug 16, 2024
f5ea9e2
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 19, 2024
a828631
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 22, 2024
1943a58
Updated summary PR pipeline to deploy PR DB
Jonathanio123 Aug 22, 2024
5804016
Run migration for PR db
Jonathanio123 Aug 22, 2024
626b787
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 22, 2024
2b4d101
Changed PR env to fra-pr.fusion-resources-app-pr
Jonathanio123 Aug 22, 2024
46496f2
Merge remote-tracking branch 'origin/chore/summary/deployment-pipelin…
Jonathanio123 Aug 22, 2024
a4555f4
Added dbTagPrefix to execute-sql-migration pr
Jonathanio123 Aug 22, 2024
06bfa50
Trigger PR pipeline
Jonathanio123 Aug 22, 2024
baff765
AzurePowerShell@5
Jonathanio123 Aug 22, 2024
c602aac
Add migration.sql script to ArtifactStagingDirectory
Jonathanio123 Aug 22, 2024
15e9ede
Print databaseConnectionString
Jonathanio123 Aug 22, 2024
77ff989
Use enablePullRequestEnv
Jonathanio123 Aug 22, 2024
e9fc6da
More testing
Jonathanio123 Aug 22, 2024
01ae8c6
Fixed typo
Jonathanio123 Aug 22, 2024
3667e45
Add PULL_REQUEST_ID env
Jonathanio123 Aug 23, 2024
8a2a64f
Removed testing variables
Jonathanio123 Aug 23, 2024
3c70c94
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 28, 2024
92a5a6d
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 29, 2024
4706972
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 29, 2024
fe95c89
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 29, 2024
044805d
Merge branch 'master' into chore/summary/deployment-pipeline
Jonathanio123 Aug 29, 2024
36d8971
Trigger resources PR pipeline
Jonathanio123 Aug 29, 2024
3b44943
Fix missing dbTagPrefix from api-pr-pipeline.yml
Jonathanio123 Aug 29, 2024
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
5 changes: 5 additions & 0 deletions pipelines/api-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ variables:
subscriptionServiceProd: 'FRA Automation Prod'
deploymentManifest: '$(Pipeline.Workspace)/k8s-deployment/deployment-test-env.yml'
fullImageName: $(fusionAcr)/$(imageName)
dbTagPrefix: resources

stages:
- stage: BuildDockerImage
Expand Down Expand Up @@ -122,6 +123,7 @@ stages:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
Expand Down Expand Up @@ -177,6 +179,7 @@ stages:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
Expand Down Expand Up @@ -232,6 +235,7 @@ stages:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
Expand Down Expand Up @@ -296,6 +300,7 @@ stages:
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)

dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
Expand Down
1 change: 1 addition & 0 deletions pipelines/api-pr-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ stages:
artifact: 'k8s-deployment'
environment: '$(envName)-$(prNumber)'
azureSubscription: $(subscriptionService)
dbTagPrefix: resources


- task: KubernetesManifest@0
Expand Down
2 changes: 1 addition & 1 deletion pipelines/pr-cleanup-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
Inline: |
$activePRs = "$(activePrs)".Split(",")

$prDbs = Get-AzResource -ResourceType "Microsoft.Sql/servers/databases" -Tag @{"fusion-app-env" = "pr" } -ResourceGroupName Fusion-SQL-Test | Where-Object { $_.Tags["fusion-app"] -eq "resources" }
$prDbs = Get-AzResource -ResourceType "Microsoft.Sql/servers/databases" -Tag @{"fusion-app-env" = "pr" } -ResourceGroupName Fusion-SQL-Test | Where-Object { $_.Tags["fusion-app"] -eq "resources" -or $_.Tags["fusion-app"] -eq "summary" }

foreach ($db in $prDbs) {
if ($db.Tags["fusion-app-env"] -ne "pr") {
Expand Down
308 changes: 308 additions & 0 deletions pipelines/summary-api-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
name: $(date:yyyyMMdd)$(rev:.r)

pr: none

trigger:
branches:
include:
- master
paths:
include:
- src/Fusion.Summary.Api/*

pool:
vmImage: ubuntu-latest

resources:
repositories:
- repository: infra
name: equinor/fusion-infrastructure
type: github
endpoint: fusion-infrastructure

variables:
imageTag: $(Build.BuildNumber)
fusionAcr: 'fusioncr.azurecr.io'
imageRepo: fra/fusion-summary-api
imageName: $(imageRepo):$(imageTag)
subscriptionServiceNonProd: 'FRA Automation Non-Prod'
subscriptionServiceProd: 'FRA Automation Prod'
deploymentManifest: '$(Pipeline.Workspace)/k8s-deployment/deployment-test-env.yml'
fullImageName: $(fusionAcr)/$(imageName)
dbTagPrefix: summary

stages:
- stage: BuildDockerImage
displayName: 'Build docker image'
jobs:
- job: BuildImage
steps:
- task: Docker@2
displayName: Login to fusioncr
inputs:
command: login
containerRegistry: fusioncr
- template: templates/docker-buildx.yml@infra
parameters:
repository: $(imageRepo)
buildContext: ./src
dockerfile: src/Fusion.Summary.Api/Dockerfile
dockerPush: true
disableCache: true
tags: |
$(imageTag)
- template: templates/docker-buildx.yml@infra
parameters:
initBuilderInstance: false
repository: ''
buildContext: ./src
dockerfile: src/Fusion.Summary.Api/Dockerfile
arguments: |
--target=export
--output=type=local,dest=$(Build.ArtifactStagingDirectory)
--cache-from=type=registry,ref=fusioncachecr.azurecr.io/$(imageRepo):$(imageTag)

- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: 'src/Fusion.Summary.Api/Deployment/k8s'
Contents: |
deployment-test-env.yml
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- publish: $(Build.ArtifactStagingDirectory)
artifact: 'k8s-deployment'

- stage: DeployCI
displayName: 'Deploy to CI'
dependsOn: BuildDockerImage
condition: succeeded()
variables:
envName: 'ci'
fusionEnvironment: 'ci'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'

jobs:
- deployment: DeployCI
environment: fusion-ci.fusion-resources-app-ci
strategy:
runOnce:
deploy:
steps:
- task: AzurePowerShell@5
displayName: 'Get secrets'
inputs:
azureSubscription: $(subscriptionServiceNonProd)
ScriptType: 'InlineScript'
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
Inline: |
$secretText = Get-AzKeyVaultSecret -VaultName kv-fap-resources-ci -Name AzureAd--ClientSecret -AsPlainText
Write-Output "##vso[task.setvariable variable=clientSecret;issecret=true]$($secretText)"

- template: templates/get-appinsights-key.yml
parameters:
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)


# Load the key vault url into variable, so it can be used when replacing tokens.
- template: templates/get-keyvault-url.yml
parameters:
environment: $(envName)
variableName: envKeyVaultUrl
azureSubscription: $(subscriptionServiceNonProd)


- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'

- template: templates/execute-sql-migration.yml
parameters:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
manifests: $(deploymentManifest)

- stage: DeployFQA
displayName: 'Deploy to FQA'
dependsOn: DeployCI
condition: succeeded()
variables:
envName: 'fqa'
fusionEnvironment: 'fqa'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'

jobs:
- deployment: DeployFQA
environment: fusion-fqa.fusion-resources-app-fqa
strategy:
runOnce:
deploy:
steps:
- task: AzurePowerShell@5
displayName: 'Get secrets'
inputs:
azureSubscription: $(subscriptionServiceNonProd)
ScriptType: 'InlineScript'
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
Inline: |
$secretText = Get-AzKeyVaultSecret -VaultName kv-fap-resources-fqa -Name AzureAd--ClientSecret -AsPlainText
Write-Output "##vso[task.setvariable variable=clientSecret;issecret=true]$($secretText)"

- template: templates/get-appinsights-key.yml
parameters:
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)

# Load the key vault url into variable, so it can be used when replacing tokens.
- template: templates/get-keyvault-url.yml
parameters:
environment: $(envName)
variableName: envKeyVaultUrl
azureSubscription: $(subscriptionServiceNonProd)

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'

- template: templates/execute-sql-migration.yml
parameters:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
manifests: $(deploymentManifest)

- stage: DeployFPRD
displayName: 'Deploy to FPRD'
dependsOn: DeployFQA
condition: succeeded()
variables:
envName: 'fprd'
fusionEnvironment: 'fprd'
clientId: '97978493-9777-4d48-b38a-67b0b9cd88d2'

jobs:
- deployment: DeployFPRD
environment: fusion-prod.fusion-resources-app-fprd
strategy:
runOnce:
deploy:
steps:
- task: AzurePowerShell@5
displayName: 'Get secrets'
inputs:
azureSubscription: $(subscriptionServiceProd)
ScriptType: 'InlineScript'
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
Inline: |
$secretText = Get-AzKeyVaultSecret -VaultName kv-fap-resources-fprd -Name AzureAd--ClientSecret -AsPlainText
Write-Output "##vso[task.setvariable variable=clientSecret;issecret=true]$($secretText)"

- template: templates/get-appinsights-key.yml
parameters:
environment: $(envName)
azureSubscription: $(subscriptionServiceProd)

# Load the key vault url into variable, so it can be used when replacing tokens.
- template: templates/get-keyvault-url.yml
parameters:
environment: $(envName)
variableName: envKeyVaultUrl
azureSubscription: $(subscriptionServiceProd)

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'

- template: templates/execute-sql-migration.yml
parameters:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
manifests: $(deploymentManifest)

- template: templates/deploy-container-app.yml
parameters:
azureSubscription: $(subscriptionServiceProd)
environment: $(envName)
fusionEnvironment: $(fusionEnvironment)
clientId: $(clientId)
imageName: $(fullImageName)

- stage: DeployTR
displayName: 'Deploy to TR'
dependsOn: DeployFPRD
condition: succeeded()
variables:
envName: 'tr'
fusionEnvironment: 'tr'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'

jobs:
- deployment: DeployTR
environment: fusion-tr.fusion-resources-app-tr
strategy:
runOnce:
deploy:
steps:
- task: AzurePowerShell@5
displayName: 'Get secrets'
inputs:
azureSubscription: $(subscriptionServiceNonProd)
ScriptType: 'InlineScript'
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
Inline: |
$secretText = Get-AzKeyVaultSecret -VaultName kv-fap-resources-tr -Name AzureAd--ClientSecret -AsPlainText
Write-Output "##vso[task.setvariable variable=clientSecret;issecret=true]$($secretText)"

- template: templates/get-appinsights-key.yml
parameters:
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)

# Load the key vault url into variable, so it can be used when replacing tokens.
- template: templates/get-keyvault-url.yml
parameters:
environment: $(envName)
variableName: envKeyVaultUrl
azureSubscription: $(subscriptionServiceNonProd)

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'

- template: templates/execute-sql-migration.yml
parameters:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
manifests: $(deploymentManifest)
Loading
Loading