From ddfa90a0913c3b714a23ab2349980b7fe0018229 Mon Sep 17 00:00:00 2001 From: Refringe Date: Sat, 9 Mar 2024 14:45:39 -0500 Subject: [PATCH] Didn't work, but no error. This adds more logging. --- .gitea/workflows/build.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index bceabdb..7861bdf 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -338,35 +338,35 @@ jobs: - name: Clean Old SFTP Releases run: | cd /workspace/refringe/Build/ + echo "Preparing known_hosts for host key verification..." echo "${{ secrets.SFTP_HOST_KEY }}" > known_hosts - # Generate a batch file for sftp commands + echo "Generating initial sftp_batch.txt..." echo "cd /public" > sftp_batch.txt - # List files in the directory using sftp - FILE_LIST=$(sshpass -p "${{ secrets.SFTP_PASSWORD }}" sftp -oBatchMode=no -oPort=${{ secrets.SFTP_PORT }} -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/public <<< "ls") + echo "Listing files with sftp..." + FILE_LIST=$(sshpass -p "${{ secrets.SFTP_PASSWORD }}" sftp -oBatchMode=no -oPort=${{ secrets.SFTP_PORT }} -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/public <<< "ls" 2>&1) + echo "Files listed." - # Process each file to determine if it's older than 30 days + echo "Processing file list..." echo "$FILE_LIST" | grep -E 'SPT-(DEBUG|BLEEDING).*\.7z$' | while read -r filename; do - # Extract date from filename + echo "Processing $filename..." if [[ "$filename" =~ ([0-9]{8})\.7z$ ]]; then file_date="${BASH_REMATCH[1]}" file_date_fmt=$(date -d "${file_date:0:4}-${file_date:4:2}-${file_date:6:2}" +%s) - # Get current date minus 30 days current_date=$(date +%s) limit_date=$(date -d "@$((current_date - 30 * 24 * 3600))" +%s) - # Compare dates and write the delete command to the batch file if [[ "$file_date_fmt" -lt "$limit_date" ]]; then - echo "Deleting old file: $filename" + echo "Queueing deletion for: $filename" echo "rm \"/public/$filename\"" >> sftp_batch.txt fi fi done - # Execute batch file with sftp - sshpass -p "${{ secrets.SFTP_PASSWORD }}" sftp -oBatchMode=no -b sftp_batch.txt -oPort=${{ secrets.SFTP_PORT }} -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }} + echo "Executing deletion commands..." + sshpass -p "${{ secrets.SFTP_PASSWORD }}" sftp -oBatchMode=no -b sftp_batch.txt -oPort=${{ secrets.SFTP_PORT }} -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }} 2>&1 shell: bash - name: Upload Release to Mega