Skip to content

Commit

Permalink
seperate build and deploy pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixAnna committed Apr 14, 2024
1 parent 9ec286c commit 3c016c7
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 90 deletions.
121 changes: 121 additions & 0 deletions azure-devops/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
trigger:
branches:
include:
- develop
paths:
include:
- src/
- azure-pipelines.yml
parameters:
- name: environment
displayName: Where to deploy?
type: string
default: dev
values:
- prod
- dev
- name: imageTag
displayName: Docker image tag
type: string
default: latest

variables:
- group: ${{parameters.environment}}-variable-group
- name: env
value: ${{parameters.environment}}
- name: imageTag
value: ${{parameters.imageTag}}

pool:
name: Azure Pipelines
vmImage: 'ubuntu-latest'

jobs:
- job: runTest
displayName: Run Tests # Human-readable name for the job.
timeoutInMinutes: 5

steps:
- task: GoTool@0
displayName: 'Use Go 1.21.3'
inputs:
version: 1.21.3

- task: Go@0
displayName: 'Run Test Cases - Common'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/common'

- task: Go@0
displayName: 'Run Test Cases - Date API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/date-api'

- task: Go@0
displayName: 'Run Test Cases - Memo API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/memo-api'

- task: Go@0
displayName: 'Run Test Cases - Finance API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/finance-api'

- task: Go@0
displayName: 'Run Test Cases - User API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/user-api'
#Multi-configuration and multi-agent job options are not exported to YAML. Configure these options using documentation guidance: https://docs.microsoft.com/vsts/pipelines/process/phases

- job: buildAndPush
displayName: Build and Push Images # Human-readable name for the job.
dependsOn: runTest
timeoutInMinutes: 10

steps:
- task: Docker@2
displayName: 'Build Date Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-date-api'
Dockerfile: 'src/date-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

- task: Docker@2
displayName: 'Build Memo Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-memo-api'
Dockerfile: 'src/memo-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

- task: Docker@2
displayName: 'Build Finance Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-finance-api'
Dockerfile: 'src/finance-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

- task: Docker@2
displayName: 'Build User Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-user-api'
Dockerfile: 'src/user-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

90 changes: 0 additions & 90 deletions azure-devops/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,98 +31,8 @@ pool:
vmImage: 'ubuntu-latest'

jobs:
- job: runTest
displayName: Run Tests # Human-readable name for the job.
timeoutInMinutes: 5

steps:
- task: GoTool@0
displayName: 'Use Go 1.21.3'
inputs:
version: 1.21.3

- task: Go@0
displayName: 'Run Test Cases - Common'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/common'

- task: Go@0
displayName: 'Run Test Cases - Date API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/date-api'

- task: Go@0
displayName: 'Run Test Cases - Memo API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/memo-api'

- task: Go@0
displayName: 'Run Test Cases - Finance API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/finance-api'

- task: Go@0
displayName: 'Run Test Cases - User API'
inputs:
command: test
arguments: ./...
workingDirectory: 'src/user-api'
#Multi-configuration and multi-agent job options are not exported to YAML. Configure these options using documentation guidance: https://docs.microsoft.com/vsts/pipelines/process/phases

- job: buildAndPush
displayName: Build and Push Images # Human-readable name for the job.
dependsOn: runTest
timeoutInMinutes: 10

steps:
- task: Docker@2
displayName: 'Build Date Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-date-api'
Dockerfile: 'src/date-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

- task: Docker@2
displayName: 'Build Memo Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-memo-api'
Dockerfile: 'src/memo-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

- task: Docker@2
displayName: 'Build Finance Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-finance-api'
Dockerfile: 'src/finance-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'

- task: Docker@2
displayName: 'Build User Api image'
inputs:
containerRegistry: sharedacr
repository: 'dlw-user-api'
Dockerfile: 'src/user-api/Dockerfile'
buildContext: 'src'
tags: '$(imageTag)'


- job: provisioningInfrastructure
displayName: Apply infrastructure # Human-readable name for the job.
dependsOn: buildAndPush
timeoutInMinutes: 10

steps:
Expand Down

0 comments on commit 3c016c7

Please sign in to comment.