Commit cb150e605587ab44c837f3567fe064fa091927ba

Edward Thomson 2019-02-17T19:31:11

Merge pull request #4989 from libgit2/ethomson/ci_docs ci: publish documentation on merge

diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index a37319a..957dd27 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -130,10 +130,12 @@ jobs:
   steps:
   - script: |
       git config user.name 'Documentation Generation'
-      git config user.email 'noreply@libgit2.org'
-      docker run --rm -v /home/vsts/work/1/s:/src -w /src libgit2/docurium:test cm doc api.docurium
+      git config user.email 'libgit2@users.noreply.github.com'
+      git branch gh-pages origin/gh-pages
+      docker run --rm -v $(Build.SourcesDirectory):/src -w /src libgit2/docurium:latest cm doc api.docurium
       git checkout gh-pages
       cp -R * '$(Build.BinariesDirectory)'
+    displayName: 'Generate Documentation'
   - task: archivefiles@2
     displayName: 'Archive Documentation'
     inputs:
@@ -141,7 +143,15 @@ jobs:
       includeRootFolder: false
       archiveFile: '$(Build.ArtifactStagingDirectory)/api-documentation.zip'
   - task: publishbuildartifacts@1
-    displayName: 'Upload Documentation'
+    displayName: 'Upload Documentation Artifact'
     inputs:
       pathToPublish: '$(Build.ArtifactStagingDirectory)'
       artifactName: 'docs'
+  - script: |
+      git remote -v
+      echo 'machine github.com' > ~/.netrc
+      echo 'login $(GITHUB_USERNAME)' >> ~/.netrc
+      echo 'password $(GITHUB_PAT)' >> ~/.netrc
+      git push origin gh-pages
+    displayName: 'Publish Documentation'
+    condition: eq(variables['Build.Reason'], 'IndividualCI')