aboutsummaryrefslogtreecommitdiff
path: root/azure-pipelines.yml
blob: a99fa595d8ed679df775d698d2ad9fe2a23810db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
trigger:
- master

stages:
- stage: build
  displayName: Routine Build and Test

  jobs:
  - job: build
    displayName: Build Debug and Test
    pool:
      vmImage: 'ubuntu-18.04'
    variables:
      buildConfiguration: 'Debug'
      ASPNETCORE_ENVIRONMENT: 'Development'
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: sdk
        version: 3.1.x

    - script: |
        dotnet restore Timeline/Timeline.csproj --configfile nuget.config
        dotnet restore Timeline.Tests/Timeline.Tests.csproj --configfile nuget.config
      displayName: Dotnet Restore

    - script: dotnet test Timeline.Tests/Timeline.Tests.csproj --configuration $(buildConfiguration) --no-restore --logger trx --collect:"XPlat Code Coverage" --settings './Timeline.Tests/coverletArgs.runsettings'
      displayName: Dotnet Test

    - task: PublishTestResults@2
      condition: succeededOrFailed()
      inputs:
        testRunner: VSTest
        testResultsFiles: '**/*.trx'

    - task: PublishCodeCoverageResults@1
      condition: succeededOrFailed()
      inputs:
        codeCoverageTool: 'Cobertura'
        summaryFileLocation: '**/TestResults/*/coverage.cobertura.xml'

- stage: deploy
  displayName: Build Release and Deploy
  dependsOn: build
  condition: eq(variables['Build.SourceBranchName'], 'master')
  variables:
    buildConfiguration: 'Release'

  jobs:
  - job: build
    displayName: Build Release Artifact
    pool:
      vmImage: 'ubuntu-18.04'
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: sdk
        version: 3.1.x

    - script: dotnet publish Timeline/Timeline.csproj --configuration $(buildConfiguration) --output ./Timeline/publish/ -r linux-x64 --self-contained false
      displayName: Dotnet Publish

    - publish: Timeline/publish
      artifact: timeline

  - job: deploy
    displayName: Deploy to Server
    pool:
      vmImage: 'ubuntu-18.04'
    variables:
    - group: sshkey
    dependsOn: build
    
    steps:
    - download: current
      artifact: timeline

    - task: InstallSSHKey@0
      inputs:
        knownHostsEntry: $(knownHostsEntry)
        sshPublicKey: $(sshPublicKey)
        sshKeySecureFile: c4553c6f-a7f5-4778-b07c-763e71dd867a

    - script: |
        ssh timeline@crupest.xyz 'rm -rf /var/timeline/*'
        scp -r $PIPELINE_WORKSPACE/timeline/* timeline@crupest.xyz:/var/timeline/
        ssh timeline@crupest.xyz 'sudo systemctl restart timeline.service'
      displayName: 'Copy Files and Restart Service'