discord-bot/azure-pipelines.yml

94 lines
2.5 KiB
YAML

#trigger:
#- master
#pr:
#- master
jobs:
- job: BuildAndTest
displayName: 'Run tests'
pool:
vmImage: 'ubuntu-latest'
timeoutInMinutes: 3
steps:
- task: UseDotNet@2
displayName: 'update dotnet core sdk'
inputs:
version: "5.0.x"
- script: dotnet restore --ignore-failed-sources
displayName: 'dotnet restore (first try)'
- script: dotnet restore --ignore-failed-sources
displayName: 'dotnet restore (second try)'
- script: dotnet restore
displayName: 'dotnet restore (last try)'
- script: dotnet build --configuration Debug
displayName: 'dotnet build Debug'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: 'test'
projects: Tests/Tests.csproj
- job: DockerImage
displayName: 'Build Docker image'
condition: "and(succeeded(), eq(variables['ReleaseBranch'], variables['Build.SourceBranch']))"
dependsOn: BuildAndTest
pool:
vmImage: 'ubuntu-latest'
steps:
- script: git checkout -f $(Build.SourceBranchName)
displayName: 'create local tracking branch'
- script: git clean -dfx
displayName: 'clean build artifacts'
- task: UseDotNet@2
displayName: 'update dotnet core sdk'
inputs:
version: 5.0.x
- script: dotnet restore --ignore-failed-sources
displayName: 'dotnet restore (first try)'
- script: dotnet restore --ignore-failed-sources
displayName: 'dotnet restore (second try)'
- script: dotnet restore
displayName: 'dotnet restore (last try)'
- script: dotnet build --configuration Release
displayName: 'dotnet build Release'
# - script: "mkdir packages && cp -a /home/vsts/.nuget/packages ./packages/"
# displayName: 'copy nuget package cache for docker'
- task: Docker@2
displayName: 'logging into docker registry'
condition: succeeded()
inputs:
containerRegistry: $(DockerConnection)
command: 'login'
- task: Docker@2
displayName: 'building release docker image'
condition: "and(succeeded(), eq(variables['ReleaseKind'], 'release'))"
inputs:
repository: $(DockerRegistry)
command: 'buildAndPush'
Dockerfile: 'Dockerfile'
tags: |
$(Build.BuildId)
release-latest
latest
- task: Docker@2
displayName: 'building test docker image'
condition: "and(succeeded(), not(eq(variables['ReleaseKind'], 'release')))"
inputs:
repository: $(DockerRegistry)
command: 'buildAndPush'
Dockerfile: 'Dockerfile'
tags: test-latest