name: Build

on:
  push:
    paths-ignore:
      - "**/*.md"
      - "**/*.yml"
      - "**/*.sh"
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        block:
          - control
          - display
    defaults:
      run:
        working-directory: ${{ matrix.block }}
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: "^1.24"
          cache-dependency-path: go.sum

      - name: Setup Deno
        uses: denoland/setup-deno@v2
        if: matrix.block == 'control'
        with:
          deno-version: v2.x

      - name: Install Dependencies
        run: go mod download

      - name: Generate
        run: go generate ./...

      - name: Build
        run: go build -o plg-mudics-${{ matrix.block }} .

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: plg-mudics-${{ matrix.block }}
          path: ${{matrix.block}}/plg-mudics-${{ matrix.block }}
