Skip to content

Commit f12b40e

Browse files
committed
arreglos con version anterior
1 parent a068c63 commit f12b40e

File tree

1 file changed

+57
-45
lines changed

1 file changed

+57
-45
lines changed

.github/workflows/main.yml

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Unity WebGL Automatic Build 👽✨🚀
22

33
on:
4-
push:
5-
branches:
6-
- '1-configure-as-a-unity-package'
74
pull_request:
85
branches:
96
- 'main'
@@ -23,77 +20,92 @@ jobs:
2320
name: Unity Build 👽
2421
runs-on: ubuntu-latest
2522
steps:
26-
27-
# Step 1: Checkout the repository
23+
# Step 1: Checkout repository without LFS
2824
- name: Checkout repository
29-
uses: actions/checkout@v3
25+
uses: actions/checkout@v2
3026
with:
3127
token: ${{ secrets.PAT }}
3228

33-
# Step 2: Stash any local changes (if needed) and apply them later if necessary
34-
- name: Stash any local changes (if needed)
35-
run: |
36-
echo "Stashing local changes"
37-
git stash push --include-untracked
29+
# Step 2: Git LFS: Restore LFS files
30+
- name: Create LFS file list
31+
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
3832

39-
# Step 3: Pull the latest changes from main
40-
- name: Pull latest changes from main
33+
- name: Restore LFS cache
34+
uses: actions/cache@v2
35+
id: lfs-cache
36+
with:
37+
path: .git/lfs
38+
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
39+
40+
- name: Git LFS Pull
4141
run: |
42-
echo "Pulling latest changes from main"
43-
git pull origin main --no-rebase
42+
git lfs pull
43+
git add .
44+
git reset --hard
45+
46+
# Step 3: Cache Unity Library
47+
- uses: actions/cache@v2
48+
with:
49+
path: Library
50+
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
51+
restore-keys: |
52+
Library-
4453
45-
# Step 4: Pull Unity image and build the project using Unity Builder
54+
# Step 4: Build Unity Project
4655
- name: Build project
47-
run: |
48-
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
49-
docker run --rm \
50-
-v $GITHUB_WORKSPACE:/workspace \
51-
-e UNITY_LICENSE=$UNITY_LICENSE \
52-
-e UNITY_EMAIL=$UNITY_EMAIL \
53-
-e UNITY_PASSWORD=$UNITY_PASSWORD \
54-
-e UNITY_SERIAL=$UNITY_SERIAL \
55-
-e UNITY_VERSION=2022.3.10f1 \
56-
-e BUILD_PATH=$BUILD_PATH \
57-
-e BUILD_NAME=WebGL \
58-
-e BUILD_TARGET=WebGL \
59-
unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 /bin/bash -c "/workspace/entrypoint.sh"
56+
uses: game-ci/unity-builder@v2
6057
env:
6158
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
6259
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
6360
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
64-
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
65-
BUILD_PATH: ${{ secrets.BUILD_PATH }}
66-
GITHUB_WORKSPACE: ${{ github.workspace }}
61+
with:
62+
targetPlatform: ${{ vars.TARGET_PLATFORM }}
63+
buildsPath: ${{ vars.BUILD_PATH }}
64+
allowDirtyBuild: true
6765

68-
# Step 5: Upload build artifact
66+
# Step 5: Upload Build Artifact
6967
- name: Upload Build Artifact
70-
uses: actions/upload-artifact@v3
68+
uses: actions/upload-artifact@v2
7169
with:
72-
name: build-artifact
73-
path: ${{ secrets.BUILD_PATH }}
70+
name: ${{ vars.ARTIFACT_NAME }}
71+
path: ${{ vars.BUILD_PATH }}
72+
73+
# Step 6: Stash the build result and reset local changes
74+
- name: Stash build result and reset local changes
75+
run: |
76+
echo "Stashing build result and resetting local changes"
77+
sudo chown -R $USER:$USER ${{ vars.BUILD_PATH }}
78+
git config --global user.email "${{ secrets.GH_EMAIL }}"
79+
git config --global user.name "${{ secrets.GH_USERNAME }}"
80+
git add ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
81+
git stash push ${{ vars.BUILD_PATH }}/${{ vars.TARGET_PLATFORM }}
82+
git reset --hard
83+
sudo git clean -d -x -f
7484
75-
# Step 6: Checkout the gh-pages branch
85+
# Step 7: Checkout gh-pages branch
7686
- name: Checkout gh-pages branch
7787
run: |
7888
echo "Switching to gh-pages branch"
79-
git checkout ${ secrets.DEPLOYMENT_BRANCH }
89+
git switch -f ${{ secrets.DEPLOYMENT_BRANCH }}
90+
git reset --hard
91+
sudo git clean -d -x -f
8092
81-
# Step 7: Apply the stashed changes to the gh-pages branch
93+
# Step 8: Apply stashed changes to gh-pages branch
8294
- name: Apply stashed changes to gh-pages
8395
run: |
8496
echo "Applying stashed changes to gh-pages"
85-
git stash apply
86-
git add -A
97+
git stash apply stash@{0}
98+
git add *
8799
git commit -m "Deploying latest build to gh-pages"
88100
89-
# Step 8: Push the changes to gh-pages
101+
# Step 9: Push changes to gh-pages branch
90102
- name: Push changes to gh-pages branch
91103
run: |
92104
echo "Pushing changes to gh-pages branch"
93-
git push origin ${ secrets.DEPLOYMENT_BRANCH }
105+
git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
94106
95-
# Step 9: Clean up: Delete stashed changes (if any)
107+
# Step 10: Clean up: Delete stashed changes (if any)
96108
- name: Clean up stashed changes
97109
run: |
98-
echo "Cleaning up stashed changes (if any)"
110+
echo "Cleaning up stashed changes"
99111
git stash clear

0 commit comments

Comments
 (0)