name: Publish Documentation

on:
  push:
    branches:
    - master
    - pr

jobs:
  build:

    runs-on: windows-latest

    steps:
        
    - name: Clone NmeaParser
      uses: actions/checkout@v1

    - name: Download DocFX
      run: |
        mkdir .tools/docfx
        Invoke-WebRequest -Uri "https://github.com/dotnet/docfx/releases/download/v${env:DOCFXVERSION}/docfx.zip" -OutFile ".tools/docfx/docfx.zip"
        [System.IO.Compression.ZipFile]::ExtractToDirectory(".tools/docfx/docfx.zip", ".tools/docfx" )
      env:
        DOCFXVERSION: 2.48.1

    - name: Install NuGet
      uses: nuget/setup-nuget@v1
    
    - name: Build Documentation
      env:         
        DOCFX_SOURCE_BRANCH_NAME: master
      run: |
        nuget install memberpage -Version 2.48.1 -OutputDirectory docs
        .tools/docfx/docfx.exe docs/docfx.json
        powershell -ExecutionPolicy ByPass -command "docs\FixApiRefLinks" -Path artifacts\docs_site\api\
      
    - name: Publish Documentation
      env:
        ACCESS_TOKEN: ${{ secrets.GH_PAT }}
        BRANCH: gh-pages
        DOCSFOLDER: artifacts/docs_site
      shell: cmd
      run: |
         cd  %DOCSFOLDER%
         git init
         git config --local user.name "%GITHUB_ACTOR%"
         git config --local user.email "%GITHUB_ACTOR%@users.noreply.github.com"
         git config --local core.autocrlf false
         git add .
         git commit -m "Auto-update doc from commit %GITHUB_SHA%"
         git push --force https://%ACCESS_TOKEN%@github.com/%GITHUB_REPOSITORY%.git master:%BRANCH%
         rmdir .git /S /Q
         

Add action to auto-publish website on merge to master
Add action to auto-publish website on merge to master