Autozip v2

This commit is contained in:
Evorp
2025-12-17 14:30:40 -08:00
parent 82630762a1
commit 888c9ad252
2 changed files with 50 additions and 27 deletions

50
.github/workflows/autozip-pack.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
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: Get deployed branch
uses: actions/checkout@v6
with:
fetch-depth: 0
# 1 - zips the pack
# 2 - creates subdirectories (rsync doesn't always do that)
# 3 - transfers file to server
- name: "Zip and upload pack"
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"

View File

@@ -1,27 +0,0 @@
name: Create Pack
on:
push:
branches-ignore:
- master
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6.4
- name: Create Pack
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.SSH }}
script: |
[ ! -d "./packs/Faithful-Java-32x/${{ steps.branch-name.outputs.current_branch }}" ] && exit 1
cd "./packs/Faithful-Java-32x/${{ steps.branch-name.outputs.current_branch }}"
git pull
zip -r "Faithful 32x - ${{ steps.branch-name.outputs.current_branch }} Experimental.zip" . -x "*.git*" -x "*.github*" -x ".gitignore"
mv "Faithful 32x - ${{ steps.branch-name.outputs.current_branch }} Experimental.zip" "/var/www/html/database.faithfulpack.net/packs/32x-Java/Experimental"