mirror of
https://github.com/sp-tarkov/build.git
synced 2025-02-13 01:50:46 -05:00
Well, that didn't work. Let's try a batch file.
This commit is contained in:
parent
25777ec7e4
commit
df7d6f6c4d
@ -339,25 +339,34 @@ jobs:
|
||||
run: |
|
||||
cd /workspace/refringe/Build/
|
||||
echo "${{ secrets.SFTP_HOST_KEY }}" > known_hosts
|
||||
lftp -u ${{ secrets.SFTP_USERNAME }},${{ secrets.SFTP_PASSWORD }} sftp://${{ secrets.SFTP_HOST }}:${{ secrets.SFTP_PORT }} << EOF
|
||||
set net:timeout 20
|
||||
set net:connect-timeout 20
|
||||
set sftp:connect-program "ssh -a -x -o ConnectTimeout=20 -o UserKnownHostsFile=$(pwd)/known_hosts -o StrictHostKeyChecking=yes"
|
||||
cd /public
|
||||
cls -1 | grep -E 'SPT-(DEBUG|BLEEDING).*\.7z$' | awk '{
|
||||
match(\$0, /([0-9]{8})\.7z$/, arr);
|
||||
"date +%s" | getline current_date;
|
||||
file_date=substr(arr[1],1,4) "-" substr(arr[1],5,2) "-" substr(arr[1],7,2);
|
||||
"date -d" file_date " +%s" | getline file_date_sec;
|
||||
limit_date=current_date - (30 * 24 * 3600);
|
||||
if (file_date_sec < limit_date) {
|
||||
print \$0;
|
||||
}
|
||||
}' | while read filename; do
|
||||
echo "Deleting old file: \$filename"
|
||||
rm "\$filename"
|
||||
done
|
||||
EOF
|
||||
|
||||
# Generate a batch file for sftp commands
|
||||
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")
|
||||
|
||||
# Process each file to determine if it's older than 30 days
|
||||
echo "$FILE_LIST" | grep -E 'SPT-(DEBUG|BLEEDING).*\.7z$' | while read -r filename; do
|
||||
# Extract date from 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 "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 }}
|
||||
shell: bash
|
||||
|
||||
- name: Upload Release to Mega
|
||||
|
Loading…
x
Reference in New Issue
Block a user