# -*- mode: yaml -*-

jobs:
- job: docs
  variables:
    - group: aws-credentials
  pool:
    vmImage: ubuntu-16.04
  container:
      image: osgeo/proj-docs:latest
      options: --privileged
  timeoutInMinutes: 60
  steps:
  - script: |
      echo "current directory:" `pwd`
      cd doc
      make doxygen
    displayName: 'Make Doxygen'
  - script: |
      cd doc
      make html
    displayName: 'Make HTML'
  - script: |
      cd doc
      make latexpdf
    displayName: 'Make PDF'
  - script: |
      #export AWS_ACCESS_KEY_ID = variables['aws-credentials.AWS_ACCESS_KEY_ID']
      #export AWS_SECRET_ACCESS_KEY = variables['aws-credentials.AWS_SECRET_ACCESS_KEY']
      export AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)"
      export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)"
      cd doc/build
      aws s3 sync html "s3://pdal/docs/$(Build.SourceVersion)/html/" --acl public-read --quiet
      aws s3 cp latex/PDAL.pdf "s3://pdal/docs/$(Build.SourceVersion)/html/" --acl public-read --quiet
      echo "PDF location: https://pdal.s3.amazonaws.com/docs/$(Build.SourceVersion)/html/PDAL.pdf"
      echo "HTML location: https://pdal.s3.amazonaws.com/docs/$(Build.SourceVersion)/html/index.html"
    displayName: 'Upload https://pdal.s3.amazonaws.com/docs/$(Build.SourceVersion)/html/index.html'
    condition: in(variables['Build.Reason'], 'PullRequest')

