on: [push, pull_request, workflow_dispatch]

name: Build
jobs:
  generate:
    runs-on: ubuntu-latest
    name: Generate
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Docker Cache
        uses: ScribeMD/docker-cache@0.3.3
        with:
          key: docker-${{ runner.os }}
      - name: Use Node.js 17
        uses: actions/setup-node@v3
        with:
          node-version: 17.x
          cache: 'npm'
      - name: Install dependencies
        run: npm install
      - name: Generate unrouted PCBs
        run: npm run gen
      - name: Export DSN 
        uses: ./.github/actions/export-dsn
        with:
          boards: left right
      - name: Autoroute PCB
        uses: ./.github/actions/autoroute
        with:
          boards: left right
      - name: Import SES
        uses: ./.github/actions/import-ses
        with:
          boards: left right
      - name: DRC check
        uses: ./.github/actions/run-drc
        with:
          boards: left right
      - name: Export Gerbers
        uses: ./.github/actions/export-gerbers
        with:
          boards: left right
      - name: Persist output
        uses: actions/upload-artifact@v3
        with:
          name: routed-pcbs-and-gerbers
          path: output
