on: [push]
jobs:
  automate-ifc:
    runs-on: self-hosted
    steps:
      - name: Install checkout
        uses: https://github.com/actions/checkout@v4
        with:
          fetch-depth: 0  # OR "2" -> To retrieve the preceding commit.
      - name: Get changed files
        id: changed-files
        uses: https://github.com/tj-actions/changed-files@v42
      - name: Do computations
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          for file in ${ALL_CHANGED_FILES}; do
            echo "$file was changed"
            filename=$(basename -- "$file")
            extension="${filename##*.}"
            if [[ $extension == "py" ]]
            then
              echo "exec python file"
              python3 $file
            elif [[ $extension == "ifc" ]]
            then
              echo "ifc file"
              echo "exec extract $file"
              python3 python/extract.py $file
            else
              echo $extension
            fi
          done
          echo "commit"

          cd "/home/fordj/SOURCES/FORDJ/fordjx/hackathon-zurich/"
          ./commit.sh

