-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (104 loc) · 3.95 KB
/
Build.yml
File metadata and controls
130 lines (104 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and Deploy to Static Repo
on:
# Trigger only on pushes to these specific branches.
# Do NOT add 'pull_request' here.
push:
branches:
- main
- stoppeds-fun-stuff
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Install ffmpeg
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Copy build config
run: |
cp workflowConfig.json buildtools_config.json
- name: Run Build Script
run: |
chmod +x ./build.sh
./build.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: eaglercraft-clients
path: out/
deploy:
needs: build
# STICT CHECK: Only run if it is a PUSH event AND (is main OR is stoppeds-fun-stuff)
# This prevents PRs from ever running this job.
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stoppeds-fun-stuff')
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: eaglercraft-clients
path: out/
- name: Install Butler
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
env:
PAT: ${{ secrets.PAT }}
- name: Deploy Manually using Git and LFS
run: |
# 1. Configure Git LFS
git lfs install
# 2. Clone the destination repository
echo "Cloning destination repository..."
git clone "https://x-access-token:${{ secrets.PAT }}@github.com/StoppedwummPython/eageag.git" deploy_repo
# 3. Navigate into the cloned repository
cd deploy_repo
# 4. Configure Git user
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# 5. Logic to determine where to deploy based on the branch name
CURRENT_BRANCH="${{ github.ref_name }}"
if [ "$CURRENT_BRANCH" == "main" ]; then
echo "--- DEPLOYING MAIN TO ROOT ---"
# PRESERVE snapshit and PRESERVE index.html (unless overwritten)
echo "Cleaning specific client folders only..."
rm -rf eaglercraft_js_client eaglercraft_wasm_client
echo "Copying new files to root..."
cp -r ../out/* .
touch .nojekyll
elif [ "$CURRENT_BRANCH" == "stoppeds-fun-stuff" ]; then
echo "--- DEPLOYING TO SNAPSHIT DIRECTORY ---"
# Ensure directory exists
mkdir -p snapshit
# Clean INSIDE snapshit only
rm -rf snapshit/*
# Copy new files into the subdirectory
echo "Copying files to snapshit/..."
cp -r ../out/* snapshit/
else
# Safety catch: If we somehow got here on a different branch, fail.
echo "Error: Branch $CURRENT_BRANCH is not authorized for deployment."
exit 1
fi
# 6. Add, commit, and push
echo "Preparing to commit..."
git add .
if git diff --staged --quiet; then
echo "No changes detected. Nothing to commit."
else
echo "Committing changes..."
git commit -m "Deploy from branch $CURRENT_BRANCH | Source: ${{ github.sha }}"
echo "Pushing to remote..."
git push origin main
fi
env:
PAT: ${{ secrets.PAT }}