Automate documentation deployment

To the loot.github.io repo/site. This script has been tested locally,
aside from the final git push command.
This commit is contained in:
Oliver Hamlet
2016-07-27 22:34:21 +01:00
parent be383cfe51
commit bcdf5afdf5
2 changed files with 53 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
$docsRepoUrl = 'https://github.com/loot/loot.github.io.git'
$docsRepoPath = 'C:\projects\loot.github.io'
$docsIndex = 'docs/index.html'
$sourceFolder = $env:APPVEYOR_BUILD_FOLDER + '/docs'
$destinationFolder = 'docs/' + $env:APPVEYOR_REPO_TAG_NAME
$searchOption = '<option value="([^"]+)" selected>([^<]+)</option>'
$replaceOption = '<option value="$1">$2</option>'
$searchSelect = '(<select id="versionSelect">)'
$replaceSelect = '$1' + "`n" + ' <option value="' + $env:APPVEYOR_REPO_TAG_NAME + '" selected>v' + $env:APPVEYOR_REPO_TAG_NAME + '</option>'
$docsFiles = @(
'images'
'licenses'
'LOOT Metadata Syntax.html'
'LOOT Readme.html'
)
$commitMessage = 'Add v' + $env:APPVEYOR_REPO_TAG_NAME + ' release docs'
if ($env:APPVEYOR_REPO_TAG) {
cd 'C:\projects'
git clone $docsRepoUrl
# Edit the docs index to list and select by default the new release docs. | %{$_ -replace $searchSelect, $replaceSelect}
cd $docsRepoPath
$newDocsIndex = cat -Raw $docsIndex | %{$_ -replace $searchOption, $replaceOption} | %{$_ -replace $searchSelect, $replaceSelect}
[IO.File]::WriteAllLines($docsRepoPath + '\' + $docsIndex, $newDocsIndex)
# Add the docs to their subfolder.
foreach($file in $docsFiles) {
cp $($sourceFolder + '/' + $file) $($destinationFolder + '/' + $file) -Force -recurse
}
# Configure Git credentials
git config credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
git config user.email "oliver.hamlet+wrinklyrobot@gmail.com"
git config user.name "WrinklyRobot"
# Commit and push the changes.
git add $docsIndex $destinationFolder
git commit -m $commitMessage
git push
}