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
+7
View File
@@ -11,6 +11,10 @@ cache:
- C:\projects\boost_1_61_0\stage\lib
- C:\Program Files (x86)\Inno Setup 5
environment:
access_token:
secure: yoODjVeYw01Vg2idJgxMBOkyII/TO3yb6OZfxtzBh/F5z3ZTDW6CHBOiH4AyiX7Y
install:
- npm install
- .\node_modules\.bin\bower install
@@ -99,6 +103,9 @@ deploy:
branch: master
appveyor_repo_tag: true
on_success:
- ps: scripts\appveyor\deploy_docs.ps1
on_finish:
- ps: (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\tests.xml")
- ps: (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\api-tests.xml")
+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
}