# GitHub action to (replaces previous Travis CI tasks):
# * Run tests
# * Generate & copy documentation to ghpages repo.

name: SDK-Tests-Docs

on:
  push:
    branches: [feature/deployHelpIOPage]
  # feature/deployHelpIOPage is a testing branch on SOURCE repo
  pull_request:
    branches: [feature/deployHelpIOPage]
  # push:
  #   branches: [feature/deployHelpIOPage]

jobs:
  build:
    runs-on: ubuntu-latest
    container: pandoc/latex

    strategy:
      matrix:
        node-version: [16.x]

    steps:
    - uses: actions/checkout@v2

    - name: Use Node ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    # - run: npm ci
      # - name: Run Tests
    # - run: npm run test && npm run test-node && npm run help
    - run: npm run help    
    # - run: npm run test-node
    # - run: npm run help    
    # - name: Build Help Pages (SDK Documentation)
      # run: npm help   

    - name: Deploy Help pages to github.io repository
      id: push_directory
      uses: HGS-jamescalderon/action-SDK-copy-docs@main
      env:
        API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_DOCS }}
      with:
        source-directory: "help"
        destination-github-username: "HGS-jamescalderon"
        destination-repository-name: "geospatial-services-framework.github.io/sdk-docs/"
        user-email: james.calderon@l3harris.com
        commit-message: See ORIGIN_COMMIT from $GITHUB_REF
        # target-branch: main
        # docs_test is a testing branch on DESTINATION repo
        target-branch: docs_test
        
    - name: Test get variable exported by push-to-another-repository
      run: echo $DESTINATION_CLONED_DIRECTORY