Skip to content

Commit e4cc64e

Browse files
committed
unity builder v4
1 parent 11f9ed7 commit e4cc64e

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,26 @@ on:
44
branches:
55
- '1-configure-as-a-unity-package'
66
pull_request:
7-
branches:
7+
branches:
88
- 'main'
99
workflow_dispatch:
10-
1110
permissions:
1211
contents: read
1312
pages: write
1413
id-token: write
15-
1614
concurrency:
1715
group: "pages"
1816
cancel-in-progress: false
19-
2017
jobs:
2118
build:
2219
name: Unity Build 👽
2320
runs-on: ubuntu-latest
2421
steps:
25-
# Checkout repository
22+
# Checkout (without LFS)
2623
- name: Checkout repository
2724
uses: actions/checkout@v2
2825
with:
29-
token: ${{ secrets.PAT }}
30-
26+
token: ${{secrets.PAT}}
3127
# Git LFS
3228
- name: Create LFS file list
3329
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
@@ -41,73 +37,78 @@ jobs:
4137

4238
- name: Git LFS Pull
4339
run: |
44-
echo "Pulling LFS files..."
4540
git lfs pull
4641
git add .
4742
git reset --hard
4843
49-
# Cache Unity Library
44+
# # Cache
5045
- uses: actions/cache@v2
5146
with:
5247
path: Library
5348
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
5449
restore-keys: |
5550
Library-
5651
57-
# Unity Build
52+
# # Build
5853
- name: Build project
59-
uses: game-ci/unity-builder@v2
60-
with:
61-
unityVersion: '2022.3.10f1'
62-
targetPlatform: WebGL
63-
buildsPath: CI-Output/WebGL
64-
allowDirtyBuild: true
54+
uses: game-ci/unity-builder@v4
6555
env:
6656
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
6757
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
6858
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
69-
70-
# Debug logs
71-
- name: Log build directory
72-
run: |
73-
echo "Build Directory Contents:"
74-
ls -la CI-Output/WebGL
75-
59+
with:
60+
targetPlatform: ${{ vars.TARGET_PLATFORM }}
61+
buildsPath: ${{ vars.BUILD_PATH }}
62+
allowDirtyBuild: true
7663
# Output: Artifact
7764
- name: Upload Build Artifact
7865
uses: actions/upload-artifact@v3
7966
with:
80-
name: WebGL-Build
81-
path: CI-Output/WebGL
82-
67+
name: ${{ vars.ARTIFACT_NAME }}
68+
path: ${{ vars.BUILD_PATH }}
8369
# Deployment
84-
- name: Deployment Preparation
70+
- name: Stash build result and reset local changes
8571
run: |
86-
echo "Preparing deployment..."
72+
echo "Applying initial configs"
73+
sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
8774
git config --global user.email "${{ secrets.GH_EMAIL }}"
8875
git config --global user.name "${{ secrets.GH_USERNAME }}"
89-
sudo chown -R $USER:$USER CI-Output/WebGL
90-
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
9183
- name: Cleaning gh-pages branch
9284
run: |
93-
echo "Switching to deployment branch..."
94-
git switch -f gh-pages
85+
echo "Switch to ${{ vars.DEPLOYMENT_BRANCH }}"
86+
git switch -f ${{ vars.DEPLOYMENT_BRANCH }}
9587
git reset --hard
9688
sudo git clean -d -x -f
97-
rm -rf *
89+
rm -r *
9890
git add *
99-
git commit -m "Cleaning branch for deployment"
91+
git commit -m "cleaning branch"
10092
git push
101-
102-
- name: Copy Build to gh-pages
93+
- name: Applying stashed files to ${{ vars.DEPLOYMENT_BRANCH }}
10394
run: |
104-
echo "Copying build files to root..."
105-
cp -r CI-Output/WebGL/* .
106-
ls -la
107-
108-
- name: Push Deployment
95+
echo "Applying stash"
96+
git stash apply stash@{0}
97+
- name: Copying files to root directory
10998
run: |
110-
echo "Pushing to gh-pages branch..."
111-
git add .
112-
git commit -m "WebGL Deployment"
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
107+
run: |
108+
pwd
109+
git status
110+
git add *
111+
git commit -m "Deployment"
113112
git push
113+
git reset --hard
114+
sudo git clean -d -x -f

0 commit comments

Comments
 (0)