Skip to content

Commit b82d678

Browse files
committed
new: divided action in jobs
1 parent 1f9cae3 commit b82d678

File tree

1 file changed

+70
-28
lines changed

1 file changed

+70
-28
lines changed

.github/workflows/main.yml

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@ concurrency:
1919
cancel-in-progress: false
2020

2121
jobs:
22-
build:
23-
name: Unity Build 👽
24-
runs-on: ubuntu-22.04 # Asegúrate de usar Ubuntu 22.04 para el runner, el cual es coherente con la versión de Docker
22+
# Checkout Repository Job
23+
checkout:
24+
name: Checkout Repository
25+
runs-on: ubuntu-22.04 # Ensure Ubuntu version is consistent
2526
steps:
26-
# Checkout repository
2727
- name: Checkout repository
2828
uses: actions/checkout@v3
2929
with:
3030
token: ${{ secrets.PAT }}
31+
32+
- name: Echo Checkout Completed
33+
run: echo "Repository has been successfully checked out."
3134

32-
# Git LFS: Create file list and restore cache
35+
# Git LFS Cache and Pull Job
36+
lfs:
37+
name: Git LFS Setup and Pull
38+
runs-on: ubuntu-22.04
39+
needs: checkout # This job depends on the "checkout" job
40+
steps:
3341
- name: Create LFS file list
3442
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
35-
43+
3644
- name: Restore LFS cache
3745
uses: actions/cache@v3
3846
id: lfs-cache
@@ -48,19 +56,35 @@ jobs:
4856
git add .
4957
git reset --hard
5058
51-
# Cache Unity Library
59+
- name: Echo LFS Pull Completed
60+
run: echo "Git LFS has been pulled and reset successfully."
61+
62+
# Cache Unity Library Job
63+
cache-library:
64+
name: Unity Library Cache
65+
runs-on: ubuntu-22.04
66+
needs: lfs # This job depends on the "lfs" job
67+
steps:
5268
- uses: actions/cache@v3
5369
with:
5470
path: Library
5571
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
5672
restore-keys: |
5773
Library-
5874
59-
# Pull Unity image and Build project using Unity Builder
60-
- name: Build project
75+
- name: Echo Unity Library Cache Completed
76+
run: echo "Unity Library has been successfully cached."
77+
78+
# Build Project Job
79+
build:
80+
name: Build Unity Project
81+
runs-on: ubuntu-22.04
82+
needs: cache-library # This job depends on the "cache-library" job
83+
steps:
84+
- name: Pull Unity Image and Build Project
6185
run: |
62-
# Asegúrate de que se descarga la imagen correcta
63-
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 # Actualiza esta línea si la versión de la imagen es diferente
86+
echo "Starting to pull Unity image and build project"
87+
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
6488
docker run --rm \
6589
-v $GITHUB_WORKSPACE:/workspace \
6690
-e UNITY_LICENSE=$UNITY_LICENSE \
@@ -72,22 +96,31 @@ jobs:
7296
-e BUILD_NAME=WebGL \
7397
-e BUILD_TARGET=WebGL \
7498
unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0 /bin/bash -c "/workspace/entrypoint.sh"
75-
env:
76-
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
77-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
78-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
79-
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
80-
BUILD_PATH: ${{ secrets.BUILD_PATH }}
81-
GITHUB_WORKSPACE: ${{ github.workspace }}
82-
83-
# Upload build artifact
99+
100+
- name: Echo Build Completed
101+
run: echo "Unity build has completed successfully."
102+
103+
# Upload Build Artifact Job
104+
upload:
105+
name: Upload Build Artifact
106+
runs-on: ubuntu-22.04
107+
needs: build # This job depends on the "build" job
108+
steps:
84109
- name: Upload Build Artifact
85110
uses: actions/upload-artifact@v3
86111
with:
87112
name: build-artifact
88113
path: ${{ secrets.BUILD_PATH }}
89114

90-
# Stash build result and reset local changes
115+
- name: Echo Upload Completed
116+
run: echo "Build artifact has been uploaded successfully."
117+
118+
# Stash and Reset Job
119+
stash-reset:
120+
name: Stash Build Result and Reset Local Changes
121+
runs-on: ubuntu-22.04
122+
needs: upload # This job depends on the "upload" job
123+
steps:
91124
- name: Stash build result and reset local changes
92125
run: |
93126
echo "Applying initial configs"
@@ -99,10 +132,18 @@ jobs:
99132
git reset --hard
100133
sudo git clean -d -x -f
101134
102-
# Clean and reset the gh-pages branch
135+
- name: Echo Stash and Reset Completed
136+
run: echo "Build result has been stashed and local changes have been reset."
137+
138+
# Clean and Deploy Job
139+
deploy:
140+
name: Clean and Deploy to gh-pages
141+
runs-on: ubuntu-22.04
142+
needs: stash-reset # This job depends on the "stash-reset" job
143+
steps:
103144
- name: Cleaning gh-pages branch
104145
run: |
105-
echo "Switch to ${{ secrets.DEPLOYMENT_BRANCH }}"
146+
echo "Switching to the deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
106147
git switch -f ${{ secrets.DEPLOYMENT_BRANCH }}
107148
git reset --hard
108149
sudo git clean -d -x -f
@@ -111,13 +152,11 @@ jobs:
111152
git commit -m "cleaning branch"
112153
git push
113154
114-
# Applying stashed files to gh-pages
115-
- name: Applying stashed files to ${{ secrets.DEPLOYMENT_BRANCH }}
155+
- name: Applying stashed files to gh-pages
116156
run: |
117-
echo "Applying stash"
157+
echo "Applying stashed files to gh-pages"
118158
git stash apply stash@{0}
119159
120-
# Copying files to the root directory
121160
- name: Copying files to root directory
122161
run: |
123162
cd ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}/${{ secrets.TARGET_PLATFORM }}
@@ -128,13 +167,16 @@ jobs:
128167
ls
129168
pwd
130169
131-
# Pushing deployment to gh-pages branch
132170
- name: Pushing deployment to gh-pages branch
133171
run: |
172+
echo "Pushing deployment to gh-pages branch"
134173
pwd
135174
git status
136175
git add *
137176
git commit -m "Deployment"
138177
git push
139178
env:
140179
GH_TOKEN: ${{ secrets.PAT }} # Use the authentication token for git push
180+
181+
- name: Echo Deployment Completed
182+
run: echo "Deployment to gh-pages branch has been successfully completed."

0 commit comments

Comments
 (0)