@@ -2,28 +2,32 @@ name: Unity WebGL Automatic Build 👽✨🚀
22on :
33 push :
44 branches :
5- - ' 1-configure-as-a-unity-package'
5+ - ' 1-configure-as-a-unity-package'
66 pull_request :
7- branches :
7+ branches :
88 - ' main'
99 workflow_dispatch :
10+
1011permissions :
1112 contents : read
1213 pages : write
1314 id-token : write
15+
1416concurrency :
1517 group : " pages"
1618 cancel-in-progress : false
19+
1720jobs :
1821 build :
1922 name : Unity Build 👽
2023 runs-on : ubuntu-latest
2124 steps :
22- # Checkout (without LFS)
25+ # Checkout repository
2326 - name : Checkout repository
2427 uses : actions/checkout@v2
2528 with :
26- token : ${{secrets.PAT}}
29+ token : ${{ secrets.PAT }}
30+
2731 # Git LFS
2832 - name : Create LFS file list
2933 run : git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
@@ -37,78 +41,72 @@ jobs:
3741
3842 - name : Git LFS Pull
3943 run : |
44+ echo "Pulling LFS files..."
4045 git lfs pull
4146 git add .
4247 git reset --hard
4348
44- # # Cache
49+ # Cache Unity Library
4550 - uses : actions/cache@v2
4651 with :
4752 path : Library
4853 key : Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
4954 restore-keys : |
5055 Library-
5156
52- # # Build
57+ # Unity Build
5358 - name : Build project
5459 uses : game-ci/unity-builder@v2
5560 env :
5661 UNITY_LICENSE : ${{ secrets.UNITY_LICENSE }}
5762 UNITY_EMAIL : ${{ secrets.UNITY_EMAIL }}
5863 UNITY_PASSWORD : ${{ secrets.UNITY_PASSWORD }}
5964 with :
60- targetPlatform : ${{ vars.TARGET_PLATFORM }}
61- buildsPath : ${{ vars.BUILD_PATH }}
65+ targetPlatform : WebGL
66+ buildsPath : CI-Output/WebGL
6267 allowDirtyBuild : true
68+
69+ # Debug logs
70+ - name : Log build directory
71+ run : |
72+ echo "Build Directory Contents:"
73+ ls -la CI-Output/WebGL
74+
6375 # Output: Artifact
6476 - name : Upload Build Artifact
6577 uses : actions/upload-artifact@v3
6678 with :
67- name : ${{ vars.ARTIFACT_NAME }}
68- path : ${{ vars.BUILD_PATH }}
79+ name : WebGL-Build
80+ path : CI-Output/WebGL
81+
6982 # Deployment
70- - name : Stash build result and reset local changes
83+ - name : Deployment Preparation
7184 run : |
72- echo "Applying initial configs"
73- sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
85+ echo "Preparing deployment..."
7486 git config --global user.email "${{ secrets.GH_EMAIL }}"
7587 git config --global user.name "${{ secrets.GH_USERNAME }}"
76- echo "Stash and reset"
77- git add ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
78- git stash push ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
79- git stash list
80- git reset --hard
81- sudo git clean -d -x -f
82- # Deployment
88+ sudo chown -R $USER:$USER CI-Output/WebGL
89+
8390 - name : Cleaning gh-pages branch
8491 run : |
85- echo "Switch to ${{ vars.DEPLOYMENT_BRANCH }} "
86- git switch -f ${{ vars.DEPLOYMENT_BRANCH }}
92+ echo "Switching to deployment branch... "
93+ git switch -f gh-pages
8794 git reset --hard
8895 sudo git clean -d -x -f
89- rm -r *
96+ rm -rf *
9097 git add *
91- git commit -m "cleaning branch"
98+ git commit -m "Cleaning branch for deployment "
9299 git push
93- - name : Applying stashed files to ${{ vars.DEPLOYMENT_BRANCH }}
94- run : |
95- echo "Applying stash"
96- git stash apply stash@{0}
97- - name : Copying files to root directory
100+
101+ - name : Copy Build to gh-pages
98102 run : |
99- cd ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}/${{ vars.TARGET_PLATFORM }}
100- ls
101- cp -r * ../../../
102- cd ../../../
103- rm -r ${{ vars.BUILD_PATH }}
104- ls
105- pwd
106- - name : Pushing deployment to gh-pages branch
103+ echo "Copying build files to root..."
104+ cp -r CI-Output/WebGL/* .
105+ ls -la
106+
107+ - name : Push Deployment
107108 run : |
108- pwd
109- git status
110- git add *
111- git commit -m "Deployment"
109+ echo "Pushing to gh-pages branch..."
110+ git add .
111+ git commit -m "WebGL Deployment"
112112 git push
113- git reset --hard
114- sudo git clean -d -x -f
0 commit comments