@@ -28,62 +28,43 @@ jobs:
28
28
uses : actions/checkout@v3
29
29
with :
30
30
token : ${{ secrets.PAT }}
31
-
31
+
32
32
- name : Echo Checkout Completed
33
33
run : echo "Repository has been successfully checked out."
34
34
35
- # Git LFS Cache and Pull Job
36
- lfs :
37
- name : Git LFS Setup and Pull
35
+ # Create Temporary Branch and Sync with Main Job
36
+ sync-main :
37
+ name : Sync Temp Branch with Main
38
38
runs-on : ubuntu-22.04
39
39
needs : checkout # This job depends on the "checkout" job
40
40
steps :
41
- - name : Create LFS file list
42
- run : git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
41
+ - name : Checkout deployment branch
42
+ run : |
43
+ echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
44
+ git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
43
45
44
- - name : Restore LFS cache
45
- uses : actions/cache@v3
46
- id : lfs-cache
47
- with :
48
- path : .git/lfs
49
- key : ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
50
- restore-keys : |
51
- ${{ runner.os }}-lfs-
52
-
53
- - name : Git LFS Pull
46
+ - name : Create temporary branch
54
47
run : |
55
- git lfs pull
56
- git add .
57
- git reset --hard
58
-
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 :
68
- - uses : actions/cache@v3
69
- with :
70
- path : Library
71
- key : Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
72
- restore-keys : |
73
- Library-
48
+ echo "Creating temporary branch from ${{ secrets.DEPLOYMENT_BRANCH }}"
49
+ git checkout -b temp
50
+
51
+ - name : Pull latest changes from main
52
+ run : |
53
+ echo "Pulling latest changes from main"
54
+ git pull origin main
74
55
75
- - name : Echo Unity Library Cache Completed
76
- run : echo "Unity Library has been successfully cached ."
56
+ - name : Echo Sync Main Completed
57
+ run : echo "Temporary branch has been successfully synced with main ."
77
58
78
- # Build Project Job
59
+ # Build Unity Project Job
79
60
build :
80
61
name : Build Unity Project
81
62
runs-on : ubuntu-22.04
82
- needs : cache-library # This job depends on the "cache-library " job
63
+ needs : sync-main # This job depends on the "sync-main " job
83
64
steps :
84
65
- name : Pull Unity Image and Build Project
85
66
run : |
86
- echo "Starting to pull Unity image and build project "
67
+ echo "Starting Unity build"
87
68
docker pull unityci/editor:ubuntu-2022.3.10f1-webgl-3.1.0
88
69
docker run --rm \
89
70
-v $GITHUB_WORKSPACE:/workspace \
@@ -100,83 +81,56 @@ jobs:
100
81
- name : Echo Build Completed
101
82
run : echo "Unity build has completed successfully."
102
83
103
- # Upload Build Artifact Job
104
- upload :
105
- name : Upload Build Artifact
84
+ # Deploy to GitHub Pages Job
85
+ deploy :
86
+ name : Deploy to GitHub Pages and Upload Artifact
106
87
runs-on : ubuntu-22.04
107
88
needs : build # This job depends on the "build" job
108
89
steps :
90
+ - name : Checkout Deployment Branch
91
+ run : |
92
+ echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
93
+ git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
94
+
95
+ - name : Merge Temp Branch to Deployment Branch
96
+ run : |
97
+ echo "Merging changes from temp to deployment branch"
98
+ git merge temp --no-ff --commit -m "Merge build changes into deployment branch"
99
+
100
+ - name : Push Changes to Deployment Branch
101
+ run : |
102
+ echo "Pushing changes to deployment branch"
103
+ git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
104
+
109
105
- name : Upload Build Artifact
110
106
uses : actions/upload-artifact@v3
111
107
with :
112
108
name : build-artifact
113
109
path : ${{ secrets.BUILD_PATH }}
114
-
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 :
124
- - name : Stash build result and reset local changes
110
+
111
+ - name : Deploy to GitHub Pages
125
112
run : |
126
- echo "Applying initial configs"
127
- sudo chown -R $USER:$USER ${{ secrets.BUILD_PATH }}
128
- git config --global user.email "${{ secrets.GH_EMAIL }}"
129
- git config --global user.name "${{ secrets.GH_USERNAME }}"
130
- git add ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}
131
- git stash push ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}
132
- git reset --hard
133
- sudo git clean -d -x -f
134
-
135
- - name : Echo Stash and Reset Completed
136
- run : echo "Build result has been stashed and local changes have been reset."
113
+ echo "Deploying to GitHub Pages"
114
+ # Any deployment script or commands you need for GitHub Pages here.
115
+
116
+ - name : Echo Deployment Completed
117
+ run : echo "Deployment to GitHub Pages has been successfully completed."
137
118
138
- # Clean and Deploy Job
139
- deploy :
140
- name : Clean and Deploy to gh-pages
119
+ # Clean Temporary Branch Job
120
+ cleanup :
121
+ name : Clean Up Temporary Branch
141
122
runs-on : ubuntu-22.04
142
- needs : stash-reset # This job depends on the "stash-reset " job
123
+ needs : deploy # This job depends on the "deploy " job
143
124
steps :
144
- - name : Cleaning gh-pages branch
145
- run : |
146
- echo "Switching to the deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
147
- git switch -f ${{ secrets.DEPLOYMENT_BRANCH }}
148
- git reset --hard
149
- sudo git clean -d -x -f
150
- rm -r *
151
- git add *
152
- git commit -m "cleaning branch"
153
- git push
154
-
155
- - name : Applying stashed files to gh-pages
156
- run : |
157
- echo "Applying stashed files to gh-pages"
158
- git stash apply stash@{0}
159
-
160
- - name : Copying files to root directory
125
+ - name : Delete Temporary Branch
161
126
run : |
162
- cd ${{ secrets.BUILD_PATH }}/${{ secrets.TARGET_PLATFORM }}/${{ secrets.TARGET_PLATFORM }}
163
- ls
164
- cp -r * ../../../
165
- cd ../../../
166
- rm -r ${{ secrets.BUILD_PATH }}
167
- ls
168
- pwd
169
-
170
- - name : Pushing deployment to gh-pages branch
127
+ echo "Deleting temporary branch"
128
+ git branch -D temp
129
+
130
+ - name : Push Cleanup
171
131
run : |
172
- echo "Pushing deployment to gh-pages branch"
173
- pwd
174
- git status
175
- git add *
176
- git commit -m "Deployment"
177
- git push
178
- env :
179
- GH_TOKEN : ${{ secrets.PAT }} # Use the authentication token for git push
132
+ echo "Cleaning up remote branches"
133
+ git push origin --delete temp
180
134
181
- - name : Echo Deployment Completed
182
- run : echo "Deployment to gh-pages branch has been successfully completed ."
135
+ - name : Echo Cleanup Completed
136
+ run : echo "Temporary branch has been deleted ."
0 commit comments