name: Webpack Test

on: [pull_request, push]

jobs:
  webpack:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}

      - name: Get commit SHA
        run: echo "LATEST_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: "14"

      - name: Test-Build Webpack
        run: |
          npm install
          npm run build
          echo "Dev" > dist/VERSION
        env:
          COMMIT_HASH: ${{ env.LATEST_SHA	}}

      - name: Push to beta-release branch
        uses: s0/git-publish-subdir-action@develop
        env:
          REPO: self
          BRANCH: beta-release
          FOLDER: dist
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload Artifact
        uses: actions/upload-artifact@v2
        with:
          name: DribbblishDynamic_vDev-${{ env.LATEST_SHA	}}
          path: dist/**
