Skip to content

Commit f40a6eb

Browse files
Overhaul autozip using rsync (#59)
1 parent 99f2156 commit f40a6eb

4 files changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/autozip-pack.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Autozip Pack
2+
on:
3+
push:
4+
branches-ignore:
5+
- "main"
6+
- "master"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Set up the ssh agent (easier & faster than creating folders, config, and authorized_keys)
13+
- uses: webfactory/ssh-agent@v0.9.0
14+
with:
15+
ssh-private-key: ${{ secrets.VPS_SSH_KEY }}
16+
17+
# Saves the branch files on the runner
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
23+
# Not sure if this is needed but local testing with `act` requires it (medium-image used)
24+
- name: Install rsync
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y rsync
28+
29+
# 1 - zips the pack
30+
# 2 - creates subdirectories (rsync doesn't always do that)
31+
# 3 - transfers file to server
32+
- name: "Remote Upload"
33+
run: |
34+
echo "Creating resource pack zip..."
35+
36+
ZIP_NAME=$(echo "${{ vars.ZIP_NAME_TEMPLATE }}" | sed "s|%VERSION%|${{ github.ref_name }}|")
37+
FINAL_LOCATION="${{ vars.ZIP_PATH }}/${ZIP_NAME}.zip"
38+
39+
zip -r "${ZIP_NAME}.zip" . -x ".*" -x "*/.*"
40+
41+
echo "Creating directory ${{ vars.ZIP_PATH }} on server..."
42+
43+
SSH_ADDRESS="${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST_IP }}"
44+
45+
ssh -p ${{ secrets.VPS_SSH_PORT }} -o StrictHostKeyChecking=no \
46+
"$SSH_ADDRESS" \
47+
"mkdir -p \"${{ vars.ZIP_PATH }}\""
48+
49+
echo "Uploading file to server..."
50+
51+
rsync -havzP \
52+
-e "ssh -p ${{ secrets.VPS_SSH_PORT }} -o StrictHostKeyChecking=no" \
53+
"${ZIP_NAME}.zip" \
54+
"${SSH_ADDRESS}:${FINAL_LOCATION}"
55+
56+
echo "File uploaded to $FINAL_LOCATION"

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
11
.DS_Store
2+
.AppleDouble
3+
.LSOverride
4+
._*
5+
.DocumentRevisions-V100
6+
.fseventsd
7+
.Spotlight-V100
8+
.TemporaryItems
9+
.Trashes
10+
.VolumeIcon.icns
11+
.com.apple.timemachine.donotpresent
12+
.AppleDB
13+
.AppleDesktop
14+
Network Trash Folder
15+
Temporary Items
16+
.apdisk
17+
Thumbs.db
18+
Thumbs.db:encryptable
19+
ehthumbs.db
20+
ehthumbs_vista.db
21+
*.stackdump
22+
[Dd]esktop.ini
23+
*~
24+
.fuse_hidden*
25+
.directory
26+
.Trash-*
27+
.nfs*
28+
29+
# For testing out the autozip workflow
30+
.act-secrets.local
31+
.act-vars.local

act-secrets

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file serves as a template to define **GitHub Secrets**
2+
# for local testing using the 'act' command-line tool.
3+
#
4+
# These variables contain confidential information and are used to
5+
# authenticate with external services (like SSH, APIs, etc.) via
6+
# the syntax ${{ secrets.KEY_NAME }}.
7+
8+
# CRITICAL: The private key, with all literal newlines replaced by '\n'.
9+
VPS_SSH_KEY="-----BEGIN OPENSSH PRIVATE KEY-----\n...-----END OPENSSH PRIVATE KEY-----"
10+
11+
# The username used to log into the remote host.
12+
VPS_USERNAME="vattic"
13+
14+
# The port used to log into the remote host.
15+
VPS_PORT="22"
16+
17+
# The IP address or domain name of the remote server.
18+
VPS_HOST_IP="127.0.0.1"

act-vars

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file serves as a template to define **GitHub Workflow Variables (vars)**
2+
# for local testing using the 'act' command-line tool.
3+
#
4+
# It should contain KEY=VALUE pairs for variables accessed in your workflow
5+
# via the syntax ${{ vars.KEY_NAME }}. These values are not secrets and are
6+
# used to control build behavior (e.g., naming artifacts or specifying versions).
7+
8+
# The name of the zip file on the remote server, with the branch name replaced with %VERSION%
9+
ZIP_NAME_TEMPLATE="Faithful: Smart Fridge Edition - %VERSION%"
10+
11+
# The absolute path to the location of all versioned zips on the remote server (no trailing slash)
12+
ZIP_PATH="/home/vattic/packs/fridge"

0 commit comments

Comments
 (0)