name: 'Autoroute'
description: 'Autoroute a given DSN file to SES with FreeRouting'
inputs:
  boards:
    description: 'Specctra SES output file'
    required: true
runs:
  using: 'docker'
  image: 'docker://soundmonster/freerouting_cli:v0.1.0'
  entrypoint: '/bin/sh'
  args:
    - '-c'
    - |
      for board in ${{ inputs.boards }};
      do
        echo "Processing $board";
        if [ -e ergogen/output/pcbs/${board}.ses ]; then
          echo "Cleaning up ergogen/output/pcbs/${board}.ses";
          rm -f ergogen/output/pcbs/${board}.ses;
        fi
        if [ -e ergogen/output/pcbs/${board}.dsn ]; then
          echo "Autoroute PCB";
          java -jar /opt/freerouting_cli.jar -de ergogen/output/pcbs/${board}.dsn -do ergogen/output/pcbs/${board}.ses -dr freerouting/freerouting.rules -mp 20
        fi
      done