Skip to content

Commit 49a2e36

Browse files
committed
update: main.yml
1 parent eef10a5 commit 49a2e36

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

.github/workflows/main.yml

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,128 @@
11
name: Unity WebGL Automatic Build 👽✨🚀
2+
23
on:
34
push:
45
branches:
5-
# - 'main'
66
- '1-configure-as-a-unity-package'
77
pull_request:
8-
branches:
8+
branches:
99
- 'main'
1010
workflow_dispatch:
11+
1112
permissions:
1213
contents: read
1314
pages: write
1415
id-token: write
16+
1517
concurrency:
1618
group: "pages"
1719
cancel-in-progress: false
20+
1821
jobs:
1922
build:
2023
name: Unity Build 👽
2124
runs-on: ubuntu-latest
2225
steps:
2326
# Checkout (without LFS)
2427
- name: Checkout repository
25-
uses: actions/checkout@v2
28+
uses: actions/checkout@v3
2629
with:
27-
token: ${{secrets.PAT}}
28-
# Git LFS
30+
token: ${{ secrets.PAT }}
31+
32+
# Git LFS: Create file list and restore cache
2933
- name: Create LFS file list
3034
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
3135

3236
- name: Restore LFS cache
33-
uses: actions/cache@v2
37+
uses: actions/cache@v3
3438
id: lfs-cache
3539
with:
3640
path: .git/lfs
3741
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
42+
restore-keys: |
43+
${{ runner.os }}-lfs-
3844
3945
- name: Git LFS Pull
4046
run: |
4147
git lfs pull
4248
git add .
4349
git reset --hard
4450
45-
# # Cache
46-
- uses: actions/cache@v2
51+
# Cache Unity Library
52+
- uses: actions/cache@v3
4753
with:
4854
path: Library
4955
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
5056
restore-keys: |
5157
Library-
5258
53-
# # Build
59+
# Build the project (using a Docker image)
5460
- name: Build project
5561
uses: game-ci/unity-builder@v2
5662
env:
5763
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
5864
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
5965
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
6066
with:
61-
targetPlatform: ${{ vars.TARGET_PLATFORM }}
62-
buildsPath: ${{ vars.BUILD_PATH }}
67+
targetPlatform: WebGL # Especificar directamente WebGL
68+
buildsPath: ${{ secrets.BUILD_PATH }}
6369
allowDirtyBuild: true
64-
# Output: Artifact
70+
71+
# Upload build artifact
6572
- name: Upload Build Artifact
6673
uses: actions/upload-artifact@v3
6774
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
7179
- name: Stash build result and reset local changes
7280
run: |
7381
echo "Applying initial configs"
74-
sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
82+
sudo chown -R $USER:$USER ${{ secrets.BUILD_PATH }}
7583
git config --global user.email "${{ secrets.GH_EMAIL }}"
7684
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 }}
8187
git reset --hard
8288
sudo git clean -d -x -f
83-
# Deployment
89+
90+
# Clean and reset the gh-pages branch
8491
- name: Cleaning gh-pages branch
8592
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 }}
8895
git reset --hard
8996
sudo git clean -d -x -f
9097
rm -r *
9198
git add *
9299
git commit -m "cleaning branch"
93100
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 }}
95104
run: |
96105
echo "Applying stash"
97106
git stash apply stash@{0}
107+
108+
# Copying files to the root directory
98109
- name: Copying files to root directory
99110
run: |
100-
cd ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}/${{ vars.TARGET_PLATFORM }}
111+
cd ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}/${{ secrets.TARGET_PLATFORM }}
101112
ls
102113
cp -r * ../../../
103114
cd ../../../
104-
rm -r ${{ vars.BUILD_PATH }}
115+
rm -r ${{ secrets.BUILD_PATH }}
105116
ls
106117
pwd
118+
119+
# Pushing deployment to gh-pages branch
107120
- name: Pushing deployment to gh-pages branch
108121
run: |
109122
pwd
110123
git status
111124
git add *
112125
git commit -m "Deployment"
113126
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

Comments
 (0)