name: 'Import SES to Kicad'
description: 'Import Specctra SES into a Kicad PCB'
inputs:
  boards:
    description: 'Board name'
    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}_autorouted.kicad_pcb ]; then
          echo "Cleaning up $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}_autorouted.kicad_pcb";
          rm -f $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}_autorouted.kicad_pcb;
        fi
        if [ -e $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.ses ]; then
          echo "Import SES";
          $GITHUB_WORKSPACE/kibot/import_ses.py -b $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.kicad_pcb -s $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}.ses -o $GITHUB_WORKSPACE/ergogen/output/pcbs/${board}_autorouted.kicad_pcb
        fi
      done