0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-12 20:30:44 -05:00

Didn't work, but no error. This adds more logging.

This commit is contained in:
Refringe 2024-03-09 14:45:39 -05:00
parent df7d6f6c4d
commit ddfa90a091
Signed by: Refringe
GPG Key ID: 7715B85B4A6306ED

View File

@ -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