AppVeyor for Continuous Integration

It's relatively easy to achieve site deployment nirvana with Wyam, GitHub Pages, and AppVeyor. Follow these instructions to get up and running:

  1. Create a repository for your web site code if you haven't already done so. You should typically structure this with a default input folder under the root where your web site content will go, but you can adjust these instructions and the call to Wyam if you want to use a different folder name.

  2. You'll probably want to add a .gitignore file that excludes the output folder and packages.xml, that way you can execute Wyam locally for testing without checking in the results.

  1. Set up GitHub Pages for your repository by adding an "orphaned" gh-pages branch (instructions here). You'll need to add an initial file to the new orphaned branch before it'll push to GitHub, a mostly empty text file will work fine.

  2. Switch back to the master branch and add the following appveyor.yml build script. This tells AppVeyor how to download the latest version of Wyam, use it to build your site, switch to the new gh-pages branch, and push the results of the build.

    - master
    # EDIT the encrypted version of your GitHub access token
    secure: ABCDEFG...

  - git submodule update --init --recursive
  - mkdir ..\Wyam
  - mkdir ..\output
  # Fetch the latest version of Wyam2 
  - "curl -s -o ..\\Wyam\\wyamversion.txt"
  - set /P WYAMVERSION=< ..\Wyam\wyamversion.txt
  - echo %WYAMVERSION%
  # Get and unzip the latest version of Wyam
  - ps: Start-FileDownload "$env:WYAMVERSION/Wyam2-$" -FileName "..\Wyam\"
  - 7z x ..\Wyam\ -o..\Wyam -r

  - dotnet ..\Wyam\Wyam.dll --output ..\output

  # Switch branches to gh-pages, clean the folder, copy everything in from the Wyam2 output, and commit/push
  # See for more info
  - git config --global credential.helper store
  # EDIT your Git email and name
  - git config --global $env:op_build_user_email
  - git config --global $env:op_build_user
  - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token)`n"
  - git checkout gh-pages
  - git rm -rf .
  - xcopy ..\output . /E
  # EDIT your domain name or remove if not using a custom domain
  - echo > CNAME
  # EDIT the origin of your repository - have to reset it here because AppVeyor pulls from SSH, but GitHub won't accept SSH pushes
  - git remote set-url origin
  - git add -A
  - git commit -a -m "Commit from AppVeyor"
  - git push

Note that you will need to replace the secure value with your own GitHub access token as described here. You will also need to encrypt your token in AppVeyor encrypt tool. Also look for the other EDIT comments in the file and change as appropriate.

  1. Create an account on AppVeyor if you haven't done so and add the GitHub repository as a new project. AppVeyor will pick up commits to the repository, run the build script above, and publish your new site on every commit!

While this guide is for GitHub Pages and AppVeyor, the same process should work pretty much the same way for alternate hosts and/or alternate build servers.