Skip to content

Commit 410206b

Browse files
committed
upppp
1 parent abe9fc6 commit 410206b

File tree

1 file changed

+49
-34
lines changed

1 file changed

+49
-34
lines changed

.github/workflows/main.yml

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Unity WebGL Automatic Build 👽✨🚀
22

33
on:
4-
push:
5-
branches:
6-
- '1-configure-as-a-unity-package'
74
pull_request:
85
branches:
96
- 'main'
@@ -23,13 +20,13 @@ jobs:
2320
name: Unity Build 👽
2421
runs-on: ubuntu-latest
2522
steps:
26-
# Step 1: Checkout repository without LFS
23+
# Checkout repository
2724
- name: Checkout repository
2825
uses: actions/checkout@v2
2926
with:
3027
token: ${{ secrets.PAT }}
3128

32-
# Step 2: Git LFS: Restore LFS files
29+
# Git LFS: Create file list and restore cache
3330
- name: Create LFS file list
3431
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
3532

@@ -39,26 +36,33 @@ jobs:
3936
with:
4037
path: .git/lfs
4138
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
39+
restore-keys: |
40+
${{ runner.os }}-lfs-
4241
4342
- name: Git LFS Pull
4443
run: |
4544
git lfs pull
4645
git add .
4746
git reset --hard
4847
49-
# Step 3: Cache Unity Library
48+
# Cache Unity Library
5049
- uses: actions/cache@v2
5150
with:
5251
path: Library
5352
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
5453
restore-keys: |
5554
Library-
5655
57-
# Step 4: Build Unity Project
56+
# Build project
5857
- name: Build project
5958
run: |
6059
docker rmi $(docker images -q)
6160
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
61+
62+
# Verify that entrypoint.sh exists in the container
63+
docker run --rm unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 /bin/bash -c "ls -l /workspace"
64+
65+
# Run Unity build process
6266
docker run --rm \
6367
-v $GITHUB_WORKSPACE:/workspace \
6468
-e UNITY_LICENSE=$UNITY_LICENSE \
@@ -70,51 +74,62 @@ jobs:
7074
-e BUILD_NAME=WebGL \
7175
-e BUILD_TARGET=WebGL \
7276
unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 /bin/bash -c "/workspace/entrypoint.sh"
73-
77+
env:
78+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
79+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
80+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
81+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
82+
BUILD_PATH: ${{ secrets.BUILD_PATH }}
83+
GITHUB_WORKSPACE: ${{ github.workspace }}
7484

75-
# Step 5: Upload Build Artifact
85+
# Upload build artifact
7686
- name: Upload Build Artifact
77-
uses: actions/upload-artifact@v3
87+
uses: actions/upload-artifact@v2
7888
with:
79-
name: ${{ vars.ARTIFACT_NAME }}
80-
path: ${{ vars.BUILD_PATH }}
89+
name: WebGL-Build-Artifact
90+
path: ${{ secrets.BUILD_PATH }}
8191

82-
# Step 6: Stash the build result and reset local changes
92+
# Stash build result and reset local changes
8393
- name: Stash build result and reset local changes
8494
run: |
85-
echo "Stashing build result and resetting local changes"
86-
sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
95+
echo "Applying initial configs"
96+
sudo chown -R $USER:$USER ${{ secrets.BUILD_PATH }}
8797
git config --global user.email "${{ secrets.GH_EMAIL }}"
8898
git config --global user.name "${{ secrets.GH_USERNAME }}"
89-
git add ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
90-
git stash push ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
99+
echo "Stash and reset"
100+
git add ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}
101+
git stash push ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}
102+
git stash list
91103
git reset --hard
92104
sudo git clean -d -x -f
93105
94-
# Step 7: Checkout gh-pages branch
95-
- name: Checkout gh-pages branch
106+
# Apply stashed files to gh-pages branch
107+
- name: Switch to gh-pages branch and apply build artifact
96108
run: |
97-
echo "Switching to gh-pages branch"
109+
echo "Switch to gh-pages branch"
98110
git switch -f ${{ secrets.DEPLOYMENT_BRANCH }}
99111
git reset --hard
100112
sudo git clean -d -x -f
113+
git add *
114+
git commit -m "Cleaning gh-pages branch"
115+
git push
101116
102-
# Step 8: Apply stashed changes to gh-pages branch
103-
- name: Apply stashed changes to gh-pages
117+
- name: Apply stashed files to gh-pages branch
104118
run: |
105-
echo "Applying stashed changes to gh-pages"
119+
echo "Applying stash"
106120
git stash apply stash@{0}
107-
git add *
108-
git commit -m "Deploying latest build to gh-pages"
109-
110-
# Step 9: Push changes to gh-pages branch
111-
- name: Push changes to gh-pages branch
121+
122+
# Copy build result to root directory
123+
- name: Copying files to root directory
112124
run: |
113-
echo "Pushing changes to gh-pages branch"
114-
git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
125+
cd ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}/${{ secrets.TARGET_PLATFORM }}
126+
cp -r * ../../../
127+
cd ../../../
128+
rm -r ${{ secrets.BUILD_PATH }}
115129
116-
# Step 10: Clean up: Delete stashed changes (if any)
117-
- name: Clean up stashed changes
130+
# Push deployment to gh-pages branch
131+
- name: Push deployment to gh-pages branch
118132
run: |
119-
echo "Cleaning up stashed changes"
120-
git stash clear
133+
git add *
134+
git commit -m "Deployment to gh-pages"
135+
git push

0 commit comments

Comments
 (0)