0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-13 04:50:46 -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 - name: Clean Old SFTP Releases
run: | run: |
cd /workspace/refringe/Build/ cd /workspace/refringe/Build/
echo "Preparing known_hosts for host key verification..."
echo "${{ secrets.SFTP_HOST_KEY }}" > known_hosts 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 echo "cd /public" > sftp_batch.txt
# List files in the directory using sftp 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") 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 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 if [[ "$filename" =~ ([0-9]{8})\.7z$ ]]; then
file_date="${BASH_REMATCH[1]}" file_date="${BASH_REMATCH[1]}"
file_date_fmt=$(date -d "${file_date:0:4}-${file_date:4:2}-${file_date:6:2}" +%s) 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) current_date=$(date +%s)
limit_date=$(date -d "@$((current_date - 30 * 24 * 3600))" +%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 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 echo "rm \"/public/$filename\"" >> sftp_batch.txt
fi fi
fi fi
done done
# Execute batch file with sftp 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 }} 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 shell: bash
- name: Upload Release to Mega - name: Upload Release to Mega