name: Deploy dev build

on:
  push:
    branches:
      - master

jobs:
  deploy-dev:
    runs-on: ubuntu-20.04

    steps:
    - name: Install git
      run: |
        sudo apt-get install -y software-properties-common \
        && sudo apt-get update \
        && sudo add-apt-repository -y ppa:git-core/ppa \
        && sudo apt-get update \
        && sudo apt-get install -y git

    - name: Check out repository code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: Install dependencies
      run: yarn install

    - name: Build
      run: yarn run full-build
      env:
        SENTRY_ENABLED: true
        SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
        SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
        SENTRY_URL: ${{ secrets.SENTRY_URL }}
        SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
        SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
        SENTRY_NO_PROGRESS_BAR: 1
        
    - name: Deploy to dev server
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.DEV_DEPLOY_HOST }}
        username: ${{ secrets.DEV_DEPLOY_USER }}
        key: ${{ secrets.DEV_DEPLOY_KEY }}
        port: ${{ secrets.DEV_DEPLOY_PORT }}
        source: "build"
        target: ${{ secrets.DEV_DEPLOY_ROOT }}
        rm: true
