name: Update api docs
on:
  schedule:
    - cron:  '0 0 * * *'
jobs:
  createPullRequest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v1
      - run: npm install -g jsdoc
      - uses: actions/checkout@v2
        with:
          path: source
      - uses: actions/checkout@v2
        with:
          ref: gh-pages
          path: out
      - name: Update jsdoc
        run: |
          cd source
          npm ci
          jsdoc -c jsdoc.json -d ../out
          cd ../out
          git add .
          git config --local user.email "mshima@users.noreply.github.com"
          git config --local user.name "Marcelo Shima"
          git commit -a -m "Update api docs" || true
      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: Update api docs
          committer: Marcelo Shima <mshima@users.noreply.github.com>
          author: Marcelo Shima <mshima@users.noreply.github.com>
          title: 'Update api docs'
          body: |
            Update api docs with master version
          labels: automated pr
          branch: gh-pages-master
          path: out
      - name: Check outputs
        run: |
          echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"
          echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}"

name: Update api docs
on:
  push:
    tags:
      - '*'
jobs:
  createPullRequest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v1
      - run: npm install -g jsdoc
      - uses: actions/checkout@v2
        with:
          path: source
      - uses: actions/checkout@v2
        with:
          ref: gh-pages
          path: out
      - name: Update jsdoc
        run: |
          cd source
          npm ci
          jsdoc -c jsdoc.json -d ../out
          cd ../out
          git add .
          git config --local user.email "mshima@users.noreply.github.com"
          git config --local user.name "Marcelo Shima"
          git commit -a -m "Update api docs" || true
      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: Update api docs
          committer: Marcelo Shima <mshima@users.noreply.github.com>
          author: Marcelo Shima <mshima@users.noreply.github.com>
          title: 'Update api docs'
          body: |
            Update api docs with master version
          labels: automated pr
          branch: gh-pages-master
          path: out
      - name: Check outputs
        run: |
          echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"
          echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}"

Change gh-pages update to tag creation
Change gh-pages update to tag creation