name: Reuse old wheel if possible

description:
  Reuse old wheel if possible

inputs:
  build-environment:
    description: Build environment
    required: true
  run-id:
    description: Workflow run ID
    required: true
  github-token:
    description: GitHub token
    required: true
  job-id:
    description: Job ID
    required: true
  job-name:
    description: Job name
    required: true

outputs:
  reuse:
    description: Whether the wheel is reused or not
    value: ${{ steps.check-file-changes.outputs.reuse }}

runs:
  using: composite

  steps:
    # Check out pytorch with fetch depth 0
    - name: Check file changes
      id: check-file-changes
      shell: bash
      continue-on-error: true
      env:
        GITHUB_TOKEN: ${{ inputs.github-token }}
        JOB_ID: ${{ inputs.job-id }}
        JOB_NAME: ${{ inputs.job-name }}
      run: |
        set -x
        python3 -m pip install boto3==1.35.42
        python3 ${GITHUB_ACTION_PATH}/reuse_old_whl.py \
          --build-environment "${{ inputs.build-environment }}" \
          --run-id "${{ inputs.run-id }}" \
          --github-ref "${{ github.ref }}"
