name: Build and Publish Demo Site

on:
  pull_request:
    types: closed
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.300
    - name: dotnet publish 
      run: |
        cd demo
        dotnet publish -c Release
        cp -Rv ./bin/Release/netstandard2.1/publish/wwwroot/* ../docs/
    - name: git commit
      run: |
        git config user.name $GITHUB_ACTOR
        git config user.email gh-actions-${GITHUB_ACTOR}@github.com
        git remote add gh-origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
        git add -A && git commit -m "Build demo site" 
        git push gh-origin HEAD:master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

name: Build and Publish Demo Site

on:
  push:
    branches:
    - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.300
    - name: dotnet publish 
      run: |
        cd demo
        dotnet publish -c Release
        cp -Rv ./bin/Release/netstandard2.1/publish/wwwroot/* ../docs/
    - name: git commit
      run: |
        git config user.name $GITHUB_ACTOR
        git config user.email gh-actions-${GITHUB_ACTOR}@github.com
        git remote add gh-origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
        git add -A && git commit -m "Build demo site" 
        git push gh-origin HEAD:master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Build demo on master commit
Build demo on master commit