name: Build Mau & Deploy Mau

on:
  push:
    branches:
      - mauster
  pull_request:
    branches:
      - mauster
  workflow_dispatch:

concurrency:
  group: mau
  cancel-in-progress: true

jobs:
  build:
    runs-on: self-hosted
    steps:
      - name: Checkout
        uses: actions/checkout@main
        with:
          fetch-depth: 0
      - name: Setup Node.js
        uses: actions/setup-node@main
        with:
          node-version: 16
      - name: Install dependencies
        run: npm install
      - name: Build
        run: npm run build
      - name: Test
        run: npm test -- --watch=false
  deploy:
    runs-on: self-hosted
    needs: build
    steps:
      - name: Checkout
        uses: actions/checkout@main
        with:
          fetch-depth: 0
      - name: Create .env File
        run: |
          touch .env
          echo "REACT_APP_API_URL=86.81.166.51:80" > .env
      - name: Docker Compose
        run: docker compose up -d --build