From 25777ec7e470800c4d37501b89e37fa4ca62dde6 Mon Sep 17 00:00:00 2001 From: Refringe Date: Sat, 9 Mar 2024 14:27:29 -0500 Subject: [PATCH] Updates the clean HTTPS source step to use LFTP. No terminal access. :( --- .gitea/workflows/build.yaml | 39 ++++++++++++++++++------------------- Dockerfile.node | 3 ++- README.md | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 4ddc574..d3baacd 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -43,7 +43,7 @@ jobs: if: needs.check-tag-exists.outputs.proceed == 'true' runs-on: ubuntu-latest container: - image: refringe/spt-build-node:1.0.2 + image: refringe/spt-build-node:1.0.3 outputs: build_type: ${{ steps.build-type.outputs.build_type }} steps: @@ -262,7 +262,7 @@ jobs: needs: [check-tag-exists, build-server, build-modules, build-launcher] runs-on: ubuntu-latest container: - image: refringe/spt-build-node:1.0.2 + image: refringe/spt-build-node:1.0.3 steps: - name: Clean Directory run: | @@ -337,26 +337,25 @@ jobs: - name: Clean Old SFTP Releases run: | + cd /workspace/refringe/Build/ echo "${{ secrets.SFTP_HOST_KEY }}" > known_hosts - sshpass -p "${{ secrets.SFTP_PASSWORD }}" ssh -oPort=${{ secrets.SFTP_PORT }} -oConnectTimeout=20 -oUserKnownHostsFile=known_hosts -oStrictHostKeyChecking=yes ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }} << EOF + 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 - # With a list of debug and bleeding edge builds... - ls | 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 delete old files - if [[ "\$file_date_fmt" -lt "\$limit_date" ]]; then - echo "Deleting old file: \$filename" - rm "/public/\$filename" - fi - fi + 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 shell: bash diff --git a/Dockerfile.node b/Dockerfile.node index 18c80cf..a368c01 100644 --- a/Dockerfile.node +++ b/Dockerfile.node @@ -9,8 +9,9 @@ FROM node:20.10.0-bookworm # - tree (pretty print build directory structure) # - p7zip-full (the goat) # - sshpass (for automated SSH authentication) +# - lftp (for automated SFTP commands) RUN apt-get update && \ - apt-get install -y wget git git-lfs zstd tree p7zip-full sshpass && \ + apt-get install -y wget git git-lfs zstd tree p7zip-full sshpass lftp && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/README.md b/README.md index e7f1fb0..41c4fd0 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,10 @@ Be sure to update the version number to the next available version before buildi ``` # Build and push the spt-build-node Docker image to the Docker Hub -docker build -t refringe/spt-build-node:0.0.0 -t refringe/spt-build-node:latest -f Dockerfile.node . +docker build -t refringe/spt-build-node:1.0.4 -t refringe/spt-build-node:latest -f Dockerfile.node . docker push refringe/spt-build-node --all-tags # Build and push the spt-build-dotnet Docker image to the Docker Hub -docker build -t refringe/spt-build-dotnet:0.0.0 -t refringe/spt-build-dotnet:latest -f Dockerfile.dotnet . +docker build -t refringe/spt-build-dotnet:1.0.1 -t refringe/spt-build-dotnet:latest -f Dockerfile.dotnet . docker push refringe/spt-build-dotnet --all-tags ```