name: Documentation

# Controls when the action will run. 
on:
  push:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          ref: documentation
      
      - name: Checkout and install the master
        run: |
          git reset --hard origin/master
          npm install

      - name: Generate the document
        run: npm run document

      - name: Create a commit with the document
        run: |
          git config user.name github-actions
          git config user.email github-actions@github.com
          git add -f docs
          git commit -m 'Add documentation'
          
      - name: Update the documentation branch
        run: git push -f origin documentation
          
          
          
