name: build-lesspass-pure-package

on:
  push:
    paths:
      - "packages/lesspass-pure/**"
      - "!packages/lesspass-pure/dist/**"

jobs:
  test:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - name: git hash
        run: |
          git rev-parse HEAD
      - name: test lesspass-pure package
        run: |
          cd packages/lesspass-pure
          yarn install
          yarn test

  build-and-commit-and-push:
    runs-on: ubuntu-18.04
    needs: test
    steps:
      - uses: actions/checkout@v2
        with:
          ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - name: build lesspass-pure package
        run: |
          cd packages/lesspass-pure
          yarn install
          yarn build
      - name: commit build and push
        run: |
          git config --global user.name 'botsito'
          git config --global user.email 'botsito@lesspass.com'
          git add .
          git commit -m "Auto build for lesspass-pure"
          git push
