Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions build/internal/gh-pagesUpdate.ps1
Original file line number Diff line number Diff line change
@@ -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
}
69 changes: 54 additions & 15 deletions build/templates/template-checkdocs.yml
Original file line number Diff line number Diff line change
@@ -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')
8 changes: 4 additions & 4 deletions build/templates/template-ci-pr-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,4 +60,7 @@ stages:
displayName: "Print all variables"

# Build & Test (Linux)
- template: ./template-build-test-service.yml
- 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
2 changes: 1 addition & 1 deletion docs/docs/get-started-with-factory-orchestrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down