From f40a6eb541ec34cb879ce529b5d460302622c72e Mon Sep 17 00:00:00 2001 From: Francesco Macaluso <80926434+FrancescoMaca@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:56:28 -0500 Subject: [PATCH] Overhaul autozip using rsync (#59) --- .github/workflows/autozip-pack.yml | 56 ++++++++++++++++++++++++++++++ .gitignore | 30 ++++++++++++++++ act-secrets | 18 ++++++++++ act-vars | 12 +++++++ 4 files changed, 116 insertions(+) create mode 100644 .github/workflows/autozip-pack.yml create mode 100644 act-secrets create mode 100644 act-vars diff --git a/.github/workflows/autozip-pack.yml b/.github/workflows/autozip-pack.yml new file mode 100644 index 000000000..8b24faff8 --- /dev/null +++ b/.github/workflows/autozip-pack.yml @@ -0,0 +1,56 @@ +name: Autozip Pack +on: + push: + branches-ignore: + - "main" + - "master" + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Set up the ssh agent (easier & faster than creating folders, config, and authorized_keys) + - uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.VPS_SSH_KEY }} + + # Saves the branch files on the runner + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + # Not sure if this is needed but local testing with `act` requires it (medium-image used) + - name: Install rsync + run: | + sudo apt-get update + sudo apt-get install -y rsync + + # 1 - zips the pack + # 2 - creates subdirectories (rsync doesn't always do that) + # 3 - transfers file to server + - name: "Remote Upload" + run: | + echo "Creating resource pack zip..." + + ZIP_NAME=$(echo "${{ vars.ZIP_NAME_TEMPLATE }}" | sed "s|%VERSION%|${{ github.ref_name }}|") + FINAL_LOCATION="${{ vars.ZIP_PATH }}/${ZIP_NAME}.zip" + + zip -r "${ZIP_NAME}.zip" . -x ".*" -x "*/.*" + + echo "Creating directory ${{ vars.ZIP_PATH }} on server..." + + SSH_ADDRESS="${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST_IP }}" + + ssh -p ${{ secrets.VPS_SSH_PORT }} -o StrictHostKeyChecking=no \ + "$SSH_ADDRESS" \ + "mkdir -p \"${{ vars.ZIP_PATH }}\"" + + echo "Uploading file to server..." + + rsync -havzP \ + -e "ssh -p ${{ secrets.VPS_SSH_PORT }} -o StrictHostKeyChecking=no" \ + "${ZIP_NAME}.zip" \ + "${SSH_ADDRESS}:${FINAL_LOCATION}" + + echo "File uploaded to $FINAL_LOCATION" diff --git a/.gitignore b/.gitignore index e43b0f988..78ce84d7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,31 @@ .DS_Store +.AppleDouble +.LSOverride +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +*.stackdump +[Dd]esktop.ini +*~ +.fuse_hidden* +.directory +.Trash-* +.nfs* + +# For testing out the autozip workflow +.act-secrets.local +.act-vars.local diff --git a/act-secrets b/act-secrets new file mode 100644 index 000000000..452e713c2 --- /dev/null +++ b/act-secrets @@ -0,0 +1,18 @@ +# This file serves as a template to define **GitHub Secrets** +# for local testing using the 'act' command-line tool. +# +# These variables contain confidential information and are used to +# authenticate with external services (like SSH, APIs, etc.) via +# the syntax ${{ secrets.KEY_NAME }}. + +# CRITICAL: The private key, with all literal newlines replaced by '\n'. +VPS_SSH_KEY="-----BEGIN OPENSSH PRIVATE KEY-----\n...-----END OPENSSH PRIVATE KEY-----" + +# The username used to log into the remote host. +VPS_USERNAME="vattic" + +# The port used to log into the remote host. +VPS_PORT="22" + +# The IP address or domain name of the remote server. +VPS_HOST_IP="127.0.0.1" diff --git a/act-vars b/act-vars new file mode 100644 index 000000000..20eaefa02 --- /dev/null +++ b/act-vars @@ -0,0 +1,12 @@ +# This file serves as a template to define **GitHub Workflow Variables (vars)** +# for local testing using the 'act' command-line tool. +# +# It should contain KEY=VALUE pairs for variables accessed in your workflow +# via the syntax ${{ vars.KEY_NAME }}. These values are not secrets and are +# used to control build behavior (e.g., naming artifacts or specifying versions). + +# The name of the zip file on the remote server, with the branch name replaced with %VERSION% +ZIP_NAME_TEMPLATE="Faithful: Smart Fridge Edition - %VERSION%" + +# The absolute path to the location of all versioned zips on the remote server (no trailing slash) +ZIP_PATH="/home/vattic/packs/fridge"