Skip to content

Commit 01fab6d

Browse files
Merge pull request #12 from StoppedwummPython/StoppedwummPython-patch-2
Update Build.yml
2 parents b6b208e + cf9e211 commit 01fab6d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

.github/workflows/Build.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: Build and Deploy to Static Repo
22
on:
3+
# Trigger only on pushes to these specific branches.
4+
# Do NOT add 'pull_request' here.
35
push:
46
branches:
57
- main
6-
- stoppeds-fun-stuff # Added the new branch here
8+
- stoppeds-fun-stuff
9+
710
jobs:
8-
# This job builds the client files and uploads them as an artifact
911
build:
1012
runs-on: ubuntu-latest
1113
steps:
@@ -38,10 +40,10 @@ jobs:
3840
name: eaglercraft-clients
3941
path: out/
4042

41-
# This job downloads the artifacts and deploys them to the external repository
4243
deploy:
4344
needs: build
44-
# Updated logic to run on either branch
45+
# STICT CHECK: Only run if it is a PUSH event AND (is main OR is stoppeds-fun-stuff)
46+
# This prevents PRs from ever running this job.
4547
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stoppeds-fun-stuff')
4648
runs-on: ubuntu-latest
4749
steps:
@@ -50,7 +52,7 @@ jobs:
5052
with:
5153
name: eaglercraft-clients
5254
path: out/
53-
55+
5456
- name: Install Butler
5557
run: |
5658
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
@@ -82,37 +84,37 @@ jobs:
8284
if [ "$CURRENT_BRANCH" == "main" ]; then
8385
echo "--- DEPLOYING MAIN TO ROOT ---"
8486
85-
# Clean root directory except .git folder
86-
# Using find/rm is safer than git rm for bulk wiping while keeping .git
87-
find . -maxdepth 1 ! -name '.git' ! -name '.' -exec rm -rf {} +
87+
# PRESERVE snapshit and PRESERVE index.html (unless overwritten)
88+
echo "Cleaning specific client folders only..."
89+
rm -rf eaglercraft_js_client eaglercraft_wasm_client
8890
89-
# Copy new files to root
91+
echo "Copying new files to root..."
9092
cp -r ../out/* .
9193
92-
# Create .nojekyll
9394
touch .nojekyll
9495
9596
elif [ "$CURRENT_BRANCH" == "stoppeds-fun-stuff" ]; then
9697
echo "--- DEPLOYING TO SNAPSHIT DIRECTORY ---"
9798
98-
# Create directory if it doesn't exist
99+
# Ensure directory exists
99100
mkdir -p snapshit
100101
101-
# Clean only the snapshit directory
102+
# Clean INSIDE snapshit only
102103
rm -rf snapshit/*
103104
104105
# Copy new files into the subdirectory
106+
echo "Copying files to snapshit/..."
105107
cp -r ../out/* snapshit/
106108
107109
else
108-
echo "Unknown branch $CURRENT_BRANCH. Skipping deployment."
110+
# Safety catch: If we somehow got here on a different branch, fail.
111+
echo "Error: Branch $CURRENT_BRANCH is not authorized for deployment."
109112
exit 1
110113
fi
111114
112115
# 6. Add, commit, and push
113116
echo "Preparing to commit..."
114117
115-
# 'git add .' handles both new files and deletions automatically
116118
git add .
117119
118120
if git diff --staged --quiet; then

0 commit comments

Comments
 (0)