name: main

on:
  pull_request:
    branches:
    - master

jobs:
  dependency-guard:
    runs-on: ubuntu-latest
    steps:
      - name: Block dependencies from being added to package.json
        run: |
          IFS=' ' read -r allowed <<< "native-promise-only zendesk_app_framework_sdk"
          dependencies=$(npm ls --production --depth=0 --parseable | awk '{gsub(/\/.*\//,"",$1); print}')

          for dep in $dependencies; do
            if [[ ! ${allowed[*]} =~ (^|[[:space:]])"$dep"($|[[:space:]]) ]]; then
              echo "::error ZAP SDK does not allow external dependencies, please remove \"${dep}\" dependency from package.json"
              exit 1
            fi
          done
        shell: bash
  main-job:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - env:
              TASK: lint
            command: npm run lint

          - env:
              TASK: test
            command: npm test
          
          - env:
              TASK: build
            command: npm run build

    steps:
      - uses: zendesk/checkout@v2
      - uses: zendesk/setup-node@v2.1.2
        with:
          node-version: 12.10.0
      - name: install npm modules
        run: |
          npm install standardx
      - name: ${{ matrix.env.TASK }}
        run: TASK=${{ matrix.env.TASK }} ${{ matrix.command }}

name: main

on:
  pull_request:
    branches:
    - master

jobs:
  dependency-guard:
    runs-on: ubuntu-latest
    steps:
      - uses: zendesk/checkout@v2
      - name: Block dependencies from being added to package.json
        run: |
          IFS=' ' read -r allowed <<< "native-promise-only zendesk_app_framework_sdk"
          dependencies=$(jq -r .dependencies package.json | jq  'keys' | jq .[] | sed 's/"//g')
          for dep in "${dependencies[@]}"; do
            if [[ ! ${allowed[*]} =~ (^|[[:space:]])"$dep"($|[[:space:]]) ]]; then
              echo "::error ZAP SDK does not allow external dependencies, please remove \"${dep}\" dependency from package.json"
              exit 1
            fi
          done
        shell: bash
  main-job:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - env:
              TASK: lint
            command: npm run lint

          - env:
              TASK: test
            command: npm test
          
          - env:
              TASK: build
            command: npm run build

    steps:
      - uses: zendesk/checkout@v2
      - uses: zendesk/setup-node@v2.1.2
        with:
          node-version: 12.10.0
      - name: install npm modules
        run: |
          npm install standardx
      - name: ${{ matrix.env.TASK }}
        run: TASK=${{ matrix.env.TASK }} ${{ matrix.command }}

Add package guard GA Parse package.json using jq
Add package guard GA
Parse package.json using jq
