Skip to content

Commit

Permalink
Add AppVeyor config to publish to github-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Dec 14, 2018
1 parent 84f37f7 commit 70f5bd7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -4,4 +4,5 @@ bin/
obj/
paket-files/
.vs/
*.user
*.user
publish/
22 changes: 22 additions & 0 deletions appveyor.yml
@@ -0,0 +1,22 @@
version: 0.1.{build}
image: Visual Studio 2017

build:
verbosity: minimal

branches:
only:
- master

init:
- git config --global core.autocrlf input

build_script:
- ps: dotnet publish src/WebFsc.Client/ -o $PWD/publish/ -c Release

on_success:
- ps: .\tools\gh-pages.ps1 -env appveyor

environment:
GH_TOKEN:
secure: dhFy1eZoqG4QPkKTuLFxix7QQMxaIyIpYjkvTU3CukYZz1CEOJeHfBSaT8tkPsGL
42 changes: 42 additions & 0 deletions tools/gh-pages.ps1
@@ -0,0 +1,42 @@
# pushes src/wwwroot to gh-pages branch

param ([string] $env = "local")

$msg = 'gh-pages.ps1: src/WebFsc.Client/wwwroot -> gh-pages'
$gitURL = "https://github.com/fsbolero/TryFSharpOnWasm"

write-host -foregroundColor "green" "=====> $msg"

function clearDir() {
rm -r build/gh-pages -errorAction ignore
}

if ($env -eq "appveyor") {
clearDir
$d = mkdir -force build
git clone $gitURL build/gh-pages -b gh-pages --single-branch
cd build/gh-pages
git config credential.helper "store --file=.git/credentials"
$t = $env:GH_TOKEN
$cred = "https://" + $t + ":@github.com"
$d = pwd
[System.IO.File]::WriteAllText("$pwd/.git/credentials", $cred)
git config user.name "AppVeyor"
git config user.email "websharper-support@intellifactory.com"
} else {
clearDir
cd build
git clone .. gh-pages -b gh-pages --single-branch
cd gh-pages
}

git rm -rf *
cp -r -force ../../publish/WebFsc.Client/dist/* .
echo $null >> .nojekyll
(get-content '.\index.html' -encoding utf8).replace('<base href="/"', '<base href="/TryFSharpOnWasm/"') | set-content '.\index.html' -encoding utf8
git add . 2>git.log
git commit --amend -am $msg
git push -f -u origin gh-pages
cd ../..
clearDir
write-host -foregroundColor "green" "=====> DONE"

0 comments on commit 70f5bd7

Please sign in to comment.