~mrlee/www.kamelasa.dev

ref: 9decaf4732dc7bc4510fcf23979af8657bdb01bd www.kamelasa.dev/azure/pipeline.yml -rw-r--r-- 2.4 KiB
9decaf47 — Lee Meichin Update pipeline.yml for Azure Pipelines 10 months ago
                                                                                
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
trigger:
  - master

pool:
  vmImage: 'ubuntu-latest'

jobs:
- job: build
  steps:
  - script: |
      mkdir -p ~/.local/bin $(Build.BinariesDirectory)
      curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
    displayName: Install Stack
  - task: Cache@2
    displayName: Cache Stack/GHC snapshot
    inputs:
      key: 'stack | root'
      path: .stack/
      cacheHitVar: 'STACK_SNAPSHOT_RESTORED'
  - task: Cache@2
    displayName: Cache local stack deps
    inputs:
      key: 'stack | stack.yaml.lock'
      path: .stack-work/
      cacheHitVar: 'STACK_DEPS_RESTORED'
  - script: |
      export PATH=$HOME/.local/bin:$PATH
      stack --no-terminal --stack-root $(System.DefaultWorkingDirectory)/.stack setup
    displayName: Build Snapshot
    condition: ne(variables.STACK_SNAPSHOT_RESTORED, 'true')
  - script: |
      export PATH=$HOME/.local/bin:$PATH
      stack --no-terminal --stack-root  $(System.DefaultWorkingDirectory)/.stack build
    displayName: Build Dependencies
    condition: ne(variables.STACK_DEPS_RESTORED, 'true')
  - script: |
      export PATH=$HOME/.local/bin:$PATH
      stack --no-terminal --stack-root $(System.DefaultWorkingDirectory)/.stack install --local-bin-path $(Build.BinariesDirectory)
    displayName: Build Site Executable
    condition: ne(variables.SITE_BIN_RESTORED, 'true')
  - task: PublishBuildArtifacts@1
    displayName: Save static site binary
    inputs:
      pathToPublish: $(Build.BinariesDirectory)
      artifactName: site

- job: deploy_published
  dependsOn: build
  condition: and(succeeded(), eq(variables['build.sourceBranchName'], 'master'))
  steps:
  - task: DownloadBuildArtifacts@0
    displayName: Download site binary
    inputs:
      artifactName: site
      downloadPath: $(System.DefaultWorkingDirectory)
  - script: |
      export PATH=$(System.DefaultWorkingDirectory)/site:$PATH
      chmod +x $(System.DefaultWorkingDirectory)/site/site
      site build
    displayName: Build with published posts
  - task: InstallSSHKey@0
    displayName: Setup SSH
    inputs:
      knownHostsEntry: '$(NexusKnownHost)'
      sshPublicKey: '$(NexusPublicKey)'
      sshKeySecureFile: 'nexus_deploy'
  - task: CopyFilesOverSSH@0
    displayName: Deploy to prod
    inputs:
      sshEndpoint: 'Nexus'
      sourceFolder: '_site/'
      contents: '**'
      targetFolder: '/var/www/www.mrlee.dev'
      cleanTargetFolder: true
      readyTimeout: '20000'