diff --git a/build/internal/gh-pagesUpdate.ps1 b/build/internal/gh-pagesUpdate.ps1 new file mode 100644 index 00000000..062b2f13 --- /dev/null +++ b/build/internal/gh-pagesUpdate.ps1 @@ -0,0 +1,45 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. + +# Updates the gh-pages branch with the latest documentation changes +( + [string]$RepoRoot, + [switch]$Force +) + +$zip = Join-Path $PSScriptRoot "gh-pages.zip" + +if (!(Test-Path $zip)) +{ + Write-Error "$zip not found!" +} + +if (!(Test-Path (Join-Path $RepoRoot "src/FactoryOrchestrator.sln"))) +{ + Write-Error "$RepoRoot is not a valid FactoryOrchestrator repo!" +} + +Set-Location $RepoRoot +git fetch public +git reset HEAD --hard +git clean -d -f +git checkout public/gh-pages +get-childitem $RepoRoot -Directory | remove-item -recurse -force + +# copy new website build to repro root +write-host "Extracting built website..." +Expand-Archive -Path $zip -DestinationPath $RepoRoot -Force +write-host "Extracting built website... DONE!" + +write-host "Using git commands to check for changes..." +# restore sitemap.xml, as it has a timestamp that changes on build +git restore sitemap.xml* +# add all files and check for changes +git add -A +git diff --cached --exit-code + +if ($LASTEXITCODE -ne 0) +{ + git commit -m "Update documentation" + #git push public HEAD:gh-pages --force +} diff --git a/build/templates/template-checkdocs.yml b/build/templates/template-checkdocs.yml index 75bc519e..3de91aeb 100644 --- a/build/templates/template-checkdocs.yml +++ b/build/templates/template-checkdocs.yml @@ -1,29 +1,68 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. + # Runs mkdocs to check if docs need updating on gh-pages. # Core and Client projects must be built for it to detect API changes. steps: -- script: | - cd $(FORepoRoot) - mkdir $(Build.ArtifactStagingDirectory)\Patch - pip install --upgrade pip --upgrade -r $(FORepoRoot)\docs\requirements.txt - mkdocs build --clean --config-file $(FORepoRoot)\docs\mkdocs.yml +- pwsh: | + Set-Location $(FORepoRoot) + mkdir $(Build.ArtifactStagingDirectory)/Patch + pip install --upgrade pip --upgrade -r $(FORepoRoot)/docs/requirements.txt + mkdocs build --clean --config-file $(FORepoRoot)/docs/mkdocs.yml + displayName: 'Build website' +- pwsh: | + Set-Location $(FORepoRoot) + # checkout gh-pages git reset HEAD --hard git fetch git checkout gh-pages - robocopy $(FORepoRoot)\docs\site\ $(FORepoRoot)\ /S + write-host "Checked out gh-pages branch" + if ((Test-Path "$(Build.ArtifactStagingDirectory)/gh-pages") -eq $false) + { + $null = New-Item -Path "$(Build.ArtifactStagingDirectory)/gh-pages" -ItemType Directory + } + + if ((Test-Path "$(Build.ArtifactStagingDirectory)/GitOutput") -eq $false) + { + $null = New-Item -Path "$(Build.ArtifactStagingDirectory)/GitOutput" -ItemType Directory + } + + write-host "Archiving built website..." + # backup new website + Compress-Archive -Path $(FORepoRoot)/docs/site/* -DestinationPath $(Build.ArtifactStagingDirectory)/gh-pages/gh-pages.zip -Force + write-host "Archiving built website... DONE!" + + # wipe subfolders, to ensure we also catch page and media deletions + write-host "Deleting all subfolders..." + get-childitem $(FORepoRoot) -Directory | remove-item -recurse -force + + # copy new website build to repro root + write-host "Extracting built website..." + Expand-Archive -Path $(Build.ArtifactStagingDirectory)/gh-pages/gh-pages.zip -DestinationPath $(FORepoRoot) -Force + write-host "Extracting built website... DONE!" + + write-host "Using git commands to check for changes..." + # restore sitemap.xml, as it has a timestamp that changes on build git restore sitemap.xml* + # add all files and check for changes git add -A - git status > $(Build.ArtifactStagingDirectory)\Patch\GitStatus.txt - git diff --cached --exit-code > $(Build.ArtifactStagingDirectory)\Patch\GitDiff.txt - echo ##vso[task.setvariable variable=hasChanges]%errorlevel% - git diff --cached > $(Build.ArtifactStagingDirectory)\Patch\UpdatedDocs.patch - displayName: 'Build website and check for changes' + git status | out-file $(Build.ArtifactStagingDirectory)/GitOutput/GitStatus.txt + git diff --cached --exit-code + write-host "##vso[task.setvariable variable=hasChanges]$LASTEXITCODE" + displayName: 'Check website for changes' +- task: PublishPipelineArtifact@1 + displayName: 'Publish git output artifact if website has changes' + condition: eq(variables['hasChanges'], '1') + inputs: + artifactName: GitOutput + targetPath: $(Build.ArtifactStagingDirectory)/GitOutput - task: PublishPipelineArtifact@1 - displayName: 'Publish patch file as artifact if website has changes' + displayName: 'Publish gh-pages artifact if website has changes' condition: eq(variables['hasChanges'], '1') inputs: - artifactName: UpdatedDocsPatch - targetPath: $(Build.ArtifactStagingDirectory)\Patch + artifactName: gh-pages + targetPath: $(Build.ArtifactStagingDirectory)/gh-pages - script: | - echo ##vso[task.logissue type=warning]gh-pages documentation needs updating! Use the published UpdatedDocsPatch artifact to update the gh-pages branch after this PR is completed. + echo ##vso[task.logissue type=warning]gh-pages documentation needs updating! Use the published gh-pages artifact from the CI build to update the gh-pages branch. displayName: 'Warn if website has changes' condition: eq(variables['hasChanges'], '1') diff --git a/build/templates/template-ci-pr-stages.yml b/build/templates/template-ci-pr-stages.yml index 9dac6665..8b9b8d8f 100644 --- a/build/templates/template-ci-pr-stages.yml +++ b/build/templates/template-ci-pr-stages.yml @@ -29,9 +29,6 @@ stages: displayName: 'Set BuildPlatform to x64' - template: ./template-build-app.yml - # Build docs - - template: ./template-checkdocs.yml - - job: "Compliance" pool: vmImage: windows-2019 @@ -63,4 +60,7 @@ stages: displayName: "Print all variables" # Build & Test (Linux) - - template: ./template-build-test-service.yml \ No newline at end of file + - template: ./template-build-test-service.yml + + # Build & Check docs. Do on Linux because this build is faster than Windows (no app build). + - template: ./template-checkdocs.yml diff --git a/docs/docs/get-started-with-factory-orchestrator.md b/docs/docs/get-started-with-factory-orchestrator.md index 30f246dd..13b18be1 100644 --- a/docs/docs/get-started-with-factory-orchestrator.md +++ b/docs/docs/get-started-with-factory-orchestrator.md @@ -24,7 +24,7 @@ To start the service manually, run the following from an administrator PowerShel ```PowerShell Start-Service -Name "Microsoft.FactoryOrchestrator" ``` - +TESTEST ### Install the service on Linux [Download](https://github.com/microsoft/FactoryOrchestrator/releases) and unzip the service for your target OS and architecture. Then run the included InstallFactoryOrchestratorService.sh file with bash as sudo. If you want the service to start automatically every boot, add an "enable" argument. Without this the service must be started manually every boot.