name: Rust

on:
  push:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Docment API
      run: |
        cargo doc --target x86_64-unknown-linux-gnu --target-dir .
        rm -rf ./doc ./debug
        cp ./x86_64-unknown-linux-gnu/doc ./doc -r
    - name: Commit
      run: |
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        git add -A
        git commit -m "Add Documentation"
    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: gh-pages
        force: true