diff --git a/.github/workflows/recover_s3_repository.yml b/.github/workflows/recover_s3_repository.yml index 36127eed9..3e6ec9166 100644 --- a/.github/workflows/recover_s3_repository.yml +++ b/.github/workflows/recover_s3_repository.yml @@ -46,14 +46,23 @@ jobs: steps: - name: Validate datetime run: | - set -e datetime="${{ github.event.inputs.date_month }}-${{ github.event.inputs.date_day }}-${{ github.event.inputs.date_year }} ${{ github.event.inputs.time }} +0000" # Use Python's strptome (same as s3-pit-restore) to check if it's a valid datetime python3 -c "from datetime import datetime; datetime.strptime('$datetime', '%m-%d-%Y %H:%M:%S %z')" 2> /dev/null exit_code=$? if [ $exit_code -ne 0 ]; then + echo "Invalid datetime: $datetime" + exit 1 + fi + + # check that datetime is not in the future + python3 -c "from datetime import datetime,timezone; import sys; sys.exit(1) if datetime.strptime('$datetime', '%m-%d-%Y %H:%M:%S %z') >= datetime.now(timezone.utc) else sys.exit(0)" + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo "datetime cannot be in the future: $datetime" exit 1 fi + echo "DATE_TIME=$datetime" >> $GITHUB_ENV - name: Validate path input does not have leading nor trailing slash