|
1 | 1 | name: Build and Deploy to Static Repo |
2 | 2 | on: |
| 3 | + # Trigger only on pushes to these specific branches. |
| 4 | + # Do NOT add 'pull_request' here. |
3 | 5 | push: |
4 | 6 | branches: |
5 | 7 | - main |
6 | | - - stoppeds-fun-stuff # Added the new branch here |
| 8 | + - stoppeds-fun-stuff |
| 9 | + |
7 | 10 | jobs: |
8 | | - # This job builds the client files and uploads them as an artifact |
9 | 11 | build: |
10 | 12 | runs-on: ubuntu-latest |
11 | 13 | steps: |
@@ -38,10 +40,10 @@ jobs: |
38 | 40 | name: eaglercraft-clients |
39 | 41 | path: out/ |
40 | 42 |
|
41 | | - # This job downloads the artifacts and deploys them to the external repository |
42 | 43 | deploy: |
43 | 44 | 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. |
45 | 47 | if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stoppeds-fun-stuff') |
46 | 48 | runs-on: ubuntu-latest |
47 | 49 | steps: |
|
50 | 52 | with: |
51 | 53 | name: eaglercraft-clients |
52 | 54 | path: out/ |
53 | | - |
| 55 | + |
54 | 56 | - name: Install Butler |
55 | 57 | run: | |
56 | 58 | curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default |
@@ -82,37 +84,37 @@ jobs: |
82 | 84 | if [ "$CURRENT_BRANCH" == "main" ]; then |
83 | 85 | echo "--- DEPLOYING MAIN TO ROOT ---" |
84 | 86 | |
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 |
88 | 90 | |
89 | | - # Copy new files to root |
| 91 | + echo "Copying new files to root..." |
90 | 92 | cp -r ../out/* . |
91 | 93 | |
92 | | - # Create .nojekyll |
93 | 94 | touch .nojekyll |
94 | 95 | |
95 | 96 | elif [ "$CURRENT_BRANCH" == "stoppeds-fun-stuff" ]; then |
96 | 97 | echo "--- DEPLOYING TO SNAPSHIT DIRECTORY ---" |
97 | 98 | |
98 | | - # Create directory if it doesn't exist |
| 99 | + # Ensure directory exists |
99 | 100 | mkdir -p snapshit |
100 | 101 | |
101 | | - # Clean only the snapshit directory |
| 102 | + # Clean INSIDE snapshit only |
102 | 103 | rm -rf snapshit/* |
103 | 104 | |
104 | 105 | # Copy new files into the subdirectory |
| 106 | + echo "Copying files to snapshit/..." |
105 | 107 | cp -r ../out/* snapshit/ |
106 | 108 | |
107 | 109 | 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." |
109 | 112 | exit 1 |
110 | 113 | fi |
111 | 114 |
|
112 | 115 | # 6. Add, commit, and push |
113 | 116 | echo "Preparing to commit..." |
114 | 117 | |
115 | | - # 'git add .' handles both new files and deletions automatically |
116 | 118 | git add . |
117 | 119 |
|
118 | 120 | if git diff --staged --quiet; then |
|
0 commit comments