Skip to content

Commit 8f23de3

Browse files
committed
restore
1 parent b2fdcaa commit 8f23de3

File tree

1 file changed

+83
-40
lines changed

1 file changed

+83
-40
lines changed

.github/workflows/main.yml

Lines changed: 83 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,114 @@
11
name: Unity WebGL Automatic Build 👽✨🚀
2-
32
on:
4-
push:
5-
branches:
6-
- '1-configure-as-a-unity-package'
3+
# push:
4+
# branches:
5+
# - 'main'
76
pull_request:
8-
branches:
7+
branches:
98
- 'main'
109
workflow_dispatch:
11-
1210
permissions:
13-
contents: write
11+
contents: read
1412
pages: write
1513
id-token: write
16-
1714
concurrency:
1815
group: "pages"
1916
cancel-in-progress: false
20-
2117
jobs:
2218
build:
2319
name: Unity Build 👽
2420
runs-on: ubuntu-latest
2521
steps:
26-
# 1. Checkout repository
22+
# Checkout (without LFS)
2723
- name: Checkout repository
28-
uses: actions/checkout@v3
24+
uses: actions/checkout@v2
25+
with:
26+
token: ${{secrets.PAT}}
27+
# Git LFS
28+
- name: Create LFS file list
29+
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
2930

30-
# 2. Set up Git LFS
31-
- name: Set up Git LFS
31+
- name: Restore LFS cache
32+
uses: actions/cache@v2
33+
id: lfs-cache
34+
with:
35+
path: .git/lfs
36+
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
37+
38+
- name: Git LFS Pull
3239
run: |
33-
git lfs install
3440
git lfs pull
41+
git add .
42+
git reset --hard
3543
36-
# 3. Cache Unity Library
37-
- uses: actions/cache@v3
44+
# # Cache
45+
- uses: actions/cache@v2
3846
with:
3947
path: Library
4048
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
4149
restore-keys: |
4250
Library-
4351
44-
# 4. Build project using Unity Docker
45-
- name: Build WebGL with Unity
46-
run: |
47-
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
48-
49-
docker run --rm \
50-
-v ${{ github.workspace }}:/workspace \
51-
-e UNITY_LICENSE=$UNITY_LICENSE \
52-
unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 \
53-
/bin/bash -c "/opt/unity/Editor/Unity -batchmode -nographics -quit -buildTarget WebGL -projectPath /workspace -executeMethod BuildPipeline.BuildPlayer"
54-
52+
# # Build
53+
- name: Build project
54+
uses: game-ci/unity-builder@v2
5555
env:
5656
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
57-
58-
# 5. Upload build artifact
59-
- name: Upload WebGL Build
60-
uses: actions/upload-artifact@v3
57+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
58+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
6159
with:
62-
name: WebGL-Build
63-
path: Build/WebGL/
64-
65-
# 6. Deploy to GitHub Pages
66-
- name: Deploy to GitHub Pages
67-
uses: peaceiris/actions-gh-pages@v3
60+
targetPlatform: ${{ vars.TARGET_PLATFORM }}
61+
buildsPath: ${{ vars.BUILD_PATH }}
62+
allowDirtyBuild: true
63+
# Output: Artifact
64+
- name: Upload Build Artifact
65+
uses: actions/upload-artifact@v3
6866
with:
69-
github_token: ${{ secrets.GITHUB_TOKEN }}
70-
publish_dir: Build/WebGL/
71-
publish_branch: gh-pages
67+
name: ${{ vars.ARTIFACT_NAME }}
68+
path: ${{ vars.BUILD_PATH }}
69+
# Deployment
70+
- name: Stash build result and reset local changes
71+
run: |
72+
echo "Applying initial configs"
73+
sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
74+
git config --global user.email "${{ secrets.GH_EMAIL }}"
75+
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
83+
- name: Cleaning gh-pages branch
84+
run: |
85+
echo "Switch to ${{ vars.DEPLOYMENT_BRANCH }}"
86+
git switch -f ${{ vars.DEPLOYMENT_BRANCH }}
87+
git reset --hard
88+
sudo git clean -d -x -f
89+
rm -r *
90+
git add *
91+
git commit -m "cleaning branch"
92+
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
98+
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
107+
run: |
108+
pwd
109+
git status
110+
git add *
111+
git commit -m "Deployment"
112+
git push
113+
git reset --hard
114+
sudo git clean -d -x -f

0 commit comments

Comments
 (0)