1010 workflow_dispatch :
1111
1212permissions :
13- contents : write # Permiso para escribir en el repositorio
13+ contents : read
1414 pages : write
1515 id-token : write
1616
@@ -19,62 +19,32 @@ concurrency:
1919 cancel-in-progress : false
2020
2121jobs :
22- # Checkout Repository
23- checkout :
24- name : Checkout Repository
25- runs-on : ubuntu-22.04
22+ build :
23+ name : Unity Build 👽
24+ runs-on : ubuntu-latest
2625 steps :
27- - name : Checkout repository
28- uses : actions/checkout@v3
29- with :
30- token : ${{ secrets.PAT }}
3126
32- - name : Echo Checkout Completed
33- run : echo "Repository has been successfully checked out."
34-
35- # Create Temporary Branch and Sync with Main
36- sync-main :
37- name : Sync Temp Branch with Main
38- runs-on : ubuntu-22.04
39- needs : checkout
40- steps :
27+ # Step 1: Checkout the repository
4128 - name : Checkout repository
4229 uses : actions/checkout@v3
4330 with :
4431 token : ${{ secrets.PAT }}
4532
46- - name : Checkout deployment branch
47- run : |
48- echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
49- git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
50-
51- - name : Create temporary branch from deployment branch
33+ # Step 2: Stash any local changes (if needed) and apply them later if necessary
34+ - name : Stash any local changes (if needed)
5235 run : |
53- echo "Creating temporary branch "
54- git checkout -b temp
36+ echo "Stashing local changes "
37+ git stash push --include-untracked
5538
39+ # Step 3: Pull the latest changes from main
5640 - name : Pull latest changes from main
5741 run : |
5842 echo "Pulling latest changes from main"
59- git pull origin main --rebase
43+ git pull origin main --no- rebase
6044
61- - name : Echo Sync Main Completed
62- run : echo "Temporary branch has been successfully synced with main."
63-
64- # Build Unity Project Job
65- build :
66- name : Build Unity Project
67- runs-on : ubuntu-22.04
68- needs : sync-main # This job depends on the "sync-main" job
69- steps :
70- - name : Checkout repository
71- uses : actions/checkout@v3
72- with :
73- token : ${{ secrets.PAT }}
74-
75- - name : Pull Unity Image and Build Project
45+ # Step 4: Pull Unity image and build the project using Unity Builder
46+ - name : Build project
7647 run : |
77- echo "Starting Unity build"
7848 docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
7949 docker run --rm \
8050 -v $GITHUB_WORKSPACE:/workspace \
@@ -87,80 +57,43 @@ jobs:
8757 -e BUILD_NAME=WebGL \
8858 -e BUILD_TARGET=WebGL \
8959 unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 /bin/bash -c "/workspace/entrypoint.sh"
90-
91- - name : Echo Build Completed
92- run : echo "Unity build has completed successfully."
93-
94- # Commit the Build Results and Push to Deployment Branch (if build is successful)
95- commit-and-push :
96- name : Commit and Push to Deployment Branch
97- runs-on : ubuntu-22.04
98- needs : build # This job depends on the "build" job
99- steps :
100- - name : Checkout repository
101- uses : actions/checkout@v3
102- with :
103- token : ${{ secrets.PAT }}
104-
105- - name : Checkout deployment branch
106- run : |
107- echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
108- git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
109-
110- - name : Merge temporary branch into deployment branch
111- run : |
112- echo "Merging changes from temp to deployment branch"
113- git merge temp --no-ff --commit -m "Merge build changes into deployment branch"
114-
115- - name : Push changes to deployment branch
116- run : |
117- echo "Pushing changes to deployment branch"
118- git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
119-
120- - name : Echo Commit and Push Completed
121- run : echo "Changes have been successfully committed and pushed to the deployment branch."
122-
123- # Upload Build Artifact
124- upload-artifact :
125- name : Upload Build Artifact
126- runs-on : ubuntu-22.04
127- needs : commit-and-push # This job depends on the "commit-and-push" job
128- steps :
129- - name : Checkout repository
130- uses : actions/checkout@v3
131- with :
132- token : ${{ secrets.PAT }}
133-
134- - name : Upload build artifact
60+ env :
61+ UNITY_LICENSE : ${{ secrets.UNITY_LICENSE }}
62+ UNITY_EMAIL : ${{ secrets.UNITY_EMAIL }}
63+ UNITY_PASSWORD : ${{ secrets.UNITY_PASSWORD }}
64+ UNITY_SERIAL : ${{ secrets.UNITY_SERIAL }}
65+ BUILD_PATH : ${{ secrets.BUILD_PATH }}
66+ GITHUB_WORKSPACE : ${{ github.workspace }}
67+
68+ # Step 5: Upload build artifact
69+ - name : Upload Build Artifact
13570 uses : actions/upload-artifact@v3
13671 with :
13772 name : build-artifact
138- path : ${{ secrets.BUILD_PATH }} # Ensure this points to the folder with the build output
73+ path : ${{ secrets.BUILD_PATH }}
13974
140- - name : Echo Artifact Uploaded
141- run : echo "Build artifact has been uploaded successfully."
75+ # Step 6: Checkout the gh-pages branch
76+ - name : Checkout gh-pages branch
77+ run : |
78+ echo "Switching to gh-pages branch"
79+ git checkout ${ secrets.DEPLOYMENT_BRANCH }
14280
143- # Clean up temporary branch (always delete the temp branch)
144- cleanup :
145- name : Clean Up Temporary Branch
146- runs-on : ubuntu-22.04
147- needs : upload-artifact # This job depends on the "upload-artifact" job
148- steps :
149- - name : Checkout repository
150- uses : actions/checkout@v3
151- with :
152- token : ${{ secrets.PAT }}
153-
154- - name : Delete temporary branch locally
81+ # Step 7: Apply the stashed changes to the gh-pages branch
82+ - name : Apply stashed changes to gh-pages
15583 run : |
156- echo "Deleting temporary branch"
157- git branch -D temp
158-
159- - name : Delete temporary branch remotely
84+ echo "Applying stashed changes to gh-pages"
85+ git stash apply
86+ git add -A
87+ git commit -m "Deploying latest build to gh-pages"
88+
89+ # Step 8: Push the changes to gh-pages
90+ - name : Push changes to gh-pages branch
16091 run : |
161- echo "Deleting temporary branch from remote"
162- git push origin --delete temp
163-
164- - name : Echo Cleanup Completed
165- run : echo "Temporary branch has been deleted."
92+ echo "Pushing changes to gh-pages branch"
93+ git push origin ${ secrets.DEPLOYMENT_BRANCH }
16694
95+ # Step 9: Clean up: Delete stashed changes (if any)
96+ - name : Clean up stashed changes
97+ run : |
98+ echo "Cleaning up stashed changes (if any)"
99+ git stash clear
0 commit comments