1
1
name : Unity WebGL Automatic Build 👽✨🚀
2
+
2
3
on :
3
4
push :
4
5
branches :
5
- # - 'main'
6
6
- ' 1-configure-as-a-unity-package'
7
7
pull_request :
8
- branches :
8
+ branches :
9
9
- ' main'
10
10
workflow_dispatch :
11
+
11
12
permissions :
12
13
contents : read
13
14
pages : write
14
15
id-token : write
16
+
15
17
concurrency :
16
18
group : " pages"
17
19
cancel-in-progress : false
20
+
18
21
jobs :
19
22
build :
20
23
name : Unity Build 👽
21
24
runs-on : ubuntu-latest
22
25
steps :
23
26
# Checkout (without LFS)
24
27
- name : Checkout repository
25
- uses : actions/checkout@v2
28
+ uses : actions/checkout@v3
26
29
with :
27
- token : ${{secrets.PAT}}
28
- # Git LFS
30
+ token : ${{ secrets.PAT }}
31
+
32
+ # Git LFS: Create file list and restore cache
29
33
- name : Create LFS file list
30
34
run : git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
31
35
32
36
- name : Restore LFS cache
33
- uses : actions/cache@v2
37
+ uses : actions/cache@v3
34
38
id : lfs-cache
35
39
with :
36
40
path : .git/lfs
37
41
key : ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
42
+ restore-keys : |
43
+ ${{ runner.os }}-lfs-
38
44
39
45
- name : Git LFS Pull
40
46
run : |
41
47
git lfs pull
42
48
git add .
43
49
git reset --hard
44
50
45
- # # Cache
46
- - uses : actions/cache@v2
51
+ # Cache Unity Library
52
+ - uses : actions/cache@v3
47
53
with :
48
54
path : Library
49
55
key : Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
50
56
restore-keys : |
51
57
Library-
52
58
53
- # # Build
59
+ # Build the project (using a Docker image)
54
60
- name : Build project
55
61
uses : game-ci/unity-builder@v2
56
62
env :
57
63
UNITY_LICENSE : ${{ secrets.UNITY_LICENSE }}
58
64
UNITY_EMAIL : ${{ secrets.UNITY_EMAIL }}
59
65
UNITY_PASSWORD : ${{ secrets.UNITY_PASSWORD }}
60
66
with :
61
- targetPlatform : ${{ vars.TARGET_PLATFORM }}
62
- buildsPath : ${{ vars .BUILD_PATH }}
67
+ targetPlatform : WebGL # Especificar directamente WebGL
68
+ buildsPath : ${{ secrets .BUILD_PATH }}
63
69
allowDirtyBuild : true
64
- # Output: Artifact
70
+
71
+ # Upload build artifact
65
72
- name : Upload Build Artifact
66
73
uses : actions/upload-artifact@v3
67
74
with :
68
- name : ${{ vars.ARTIFACT_NAME }}
69
- path : ${{ vars.BUILD_PATH }}
70
- # Deployment
75
+ name : build-artifact
76
+ path : ${{ secrets.BUILD_PATH }}
77
+
78
+ # Stash build result and reset local changes
71
79
- name : Stash build result and reset local changes
72
80
run : |
73
81
echo "Applying initial configs"
74
- sudo chown -R $USER:$USER ${{ vars .BUILD_PATH }}
82
+ sudo chown -R $USER:$USER ${{ secrets .BUILD_PATH }}
75
83
git config --global user.email "${{ secrets.GH_EMAIL }}"
76
84
git config --global user.name "${{ secrets.GH_USERNAME }}"
77
- echo "Stash and reset"
78
- git add ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
79
- git stash push ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
80
- git stash list
85
+ git add ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}
86
+ git stash push ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}
81
87
git reset --hard
82
88
sudo git clean -d -x -f
83
- # Deployment
89
+
90
+ # Clean and reset the gh-pages branch
84
91
- name : Cleaning gh-pages branch
85
92
run : |
86
- echo "Switch to ${{ vars .DEPLOYMENT_BRANCH }}"
87
- git switch -f ${{ vars .DEPLOYMENT_BRANCH }}
93
+ echo "Switch to ${{ secrets .DEPLOYMENT_BRANCH }}"
94
+ git switch -f ${{ secrets .DEPLOYMENT_BRANCH }}
88
95
git reset --hard
89
96
sudo git clean -d -x -f
90
97
rm -r *
91
98
git add *
92
99
git commit -m "cleaning branch"
93
100
git push
94
- - name : Applying stashed files to ${{ vars.DEPLOYMENT_BRANCH }}
101
+
102
+ # Applying stashed files to gh-pages
103
+ - name : Applying stashed files to ${{ secrets.DEPLOYMENT_BRANCH }}
95
104
run : |
96
105
echo "Applying stash"
97
106
git stash apply stash@{0}
107
+
108
+ # Copying files to the root directory
98
109
- name : Copying files to root directory
99
110
run : |
100
- cd ${{ vars .BUILD_PATH }}/${{ vars .TARGET_PLATFORM }}/${{ vars .TARGET_PLATFORM }}
111
+ cd ${{ secrets .BUILD_PATH }}/${{ secrets .TARGET_PLATFORM }}/${{ secrets .TARGET_PLATFORM }}
101
112
ls
102
113
cp -r * ../../../
103
114
cd ../../../
104
- rm -r ${{ vars .BUILD_PATH }}
115
+ rm -r ${{ secrets .BUILD_PATH }}
105
116
ls
106
117
pwd
118
+
119
+ # Pushing deployment to gh-pages branch
107
120
- name : Pushing deployment to gh-pages branch
108
121
run : |
109
122
pwd
110
123
git status
111
124
git add *
112
125
git commit -m "Deployment"
113
126
git push
114
- git reset --hard
115
- sudo git clean -d -x -f
127
+ env :
128
+ GH_TOKEN : ${{ secrets.PAT }} # Usar el token de autenticación para git push
0 commit comments