name: 'Export DSN'
description: 'Export Specctra DSN from a Kicad PCB'
inputs:
  boards:
    description: 'KiCad PCB names'
    required: true
runs:
  using: 'docker'
  image: 'docker://ghcr.io/inti-cmnb/kicad8_auto:latest'
  entrypoint: '/bin/bash'
  args:
    - '-c'
    - |
      for board in ${{ inputs.boards }};
      do
        echo "Processing $board";
        if [ -e $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.dsn ]; then
          echo "Cleaning up $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.dsn";
          rm -f $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.dsn;
        fi
        if [ -e ergogen/output/pcbs/${board}.kicad_pcb ]; then
          echo "Export DSN";
          $GITHUB_WORKSPACE/kibot/export_dsn.py -b $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.kicad_pcb -o $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.dsn 
        fi
      done