name: Generate & upload node.js documentation

on:
  push:
    branches:
      - master

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Use Node.js 16.x
        uses: actions/setup-node@v3
        with:
          node-version: 16.x

      - name: npm install and generate documentation
        run: |
          cd node
          npm i --ignore-scripts
          npx typedoc
          mv docs js

      - name: Upload
        uses: horochx/deploy-via-scp@v1.0.1
        with:
          user: ${{ secrets.USERNAME }}
          key: ${{ secrets.KEY }}
          host: "delta.chat"
          port: 22
          local: "node/js"
          remote: "/var/www/html/"
