1010 workflow_dispatch :
1111
1212permissions :
13- contents : read
13+ contents : write # Permiso para escribir en el repositorio
1414 pages : write
1515 id-token : write
1616
@@ -19,35 +19,40 @@ concurrency:
1919 cancel-in-progress : false
2020
2121jobs :
22- # Checkout Repository Job
22+ # Checkout Repository
2323 checkout :
2424 name : Checkout Repository
25- runs-on : ubuntu-22.04 # Ensure Ubuntu version is consistent
25+ runs-on : ubuntu-22.04
2626 steps :
2727 - name : Checkout repository
2828 uses : actions/checkout@v3
2929 with :
3030 token : ${{ secrets.PAT }}
31-
31+
3232 - name : Echo Checkout Completed
3333 run : echo "Repository has been successfully checked out."
3434
35- # Create Temporary Branch and Sync with Main Job
35+ # Create Temporary Branch and Sync with Main
3636 sync-main :
3737 name : Sync Temp Branch with Main
3838 runs-on : ubuntu-22.04
39- needs : checkout # This job depends on the "checkout" job
39+ needs : checkout
4040 steps :
41+ - name : Checkout repository
42+ uses : actions/checkout@v3
43+ with :
44+ token : ${{ secrets.PAT }}
45+
4146 - name : Checkout deployment branch
4247 run : |
4348 echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
4449 git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
4550
46- - name : Create temporary branch
51+ - name : Create temporary branch from deployment branch
4752 run : |
48- echo "Creating temporary branch from ${{ secrets.DEPLOYMENT_BRANCH }} "
53+ echo "Creating temporary branch"
4954 git checkout -b temp
50-
55+
5156 - name : Pull latest changes from main
5257 run : |
5358 echo "Pulling latest changes from main"
6267 runs-on : ubuntu-22.04
6368 needs : sync-main # This job depends on the "sync-main" job
6469 steps :
70+ - name : Checkout repository
71+ uses : actions/checkout@v3
72+ with :
73+ token : ${{ secrets.PAT }}
74+
6575 - name : Pull Unity Image and Build Project
6676 run : |
6777 echo "Starting Unity build"
@@ -81,56 +91,76 @@ jobs:
8191 - name : Echo Build Completed
8292 run : echo "Unity build has completed successfully."
8393
84- # Deploy to GitHub Pages Job
85- deploy :
86- name : Deploy to GitHub Pages and Upload Artifact
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
8797 runs-on : ubuntu-22.04
8898 needs : build # This job depends on the "build" job
8999 steps :
90- - name : Checkout Deployment Branch
100+ - name : Checkout repository
101+ uses : actions/checkout@v3
102+ with :
103+ token : ${{ secrets.PAT }}
104+
105+ - name : Checkout deployment branch
91106 run : |
92107 echo "Checking out deployment branch: ${{ secrets.DEPLOYMENT_BRANCH }}"
93108 git checkout ${{ secrets.DEPLOYMENT_BRANCH }}
94-
95- - name : Merge Temp Branch to Deployment Branch
109+
110+ - name : Merge temporary branch into deployment branch
96111 run : |
97112 echo "Merging changes from temp to deployment branch"
98113 git merge temp --no-ff --commit -m "Merge build changes into deployment branch"
99-
100- - name : Push Changes to Deployment Branch
114+
115+ - name : Push changes to deployment branch
101116 run : |
102117 echo "Pushing changes to deployment branch"
103118 git push origin ${{ secrets.DEPLOYMENT_BRANCH }}
104119
105- - name : Upload Build Artifact
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
106135 uses : actions/upload-artifact@v3
107136 with :
108137 name : build-artifact
109- path : ${{ secrets.BUILD_PATH }}
110-
111- - name : Deploy to GitHub Pages
112- run : |
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."
138+ path : ${{ secrets.BUILD_PATH }} # Ensure this points to the folder with the build output
118139
119- # Clean Temporary Branch Job
140+ - name : Echo Artifact Uploaded
141+ run : echo "Build artifact has been uploaded successfully."
142+
143+ # Clean up temporary branch (always delete the temp branch)
120144 cleanup :
121145 name : Clean Up Temporary Branch
122146 runs-on : ubuntu-22.04
123- needs : deploy # This job depends on the "deploy " job
147+ needs : upload-artifact # This job depends on the "upload-artifact " job
124148 steps :
125- - name : Delete Temporary Branch
149+ - name : Checkout repository
150+ uses : actions/checkout@v3
151+ with :
152+ token : ${{ secrets.PAT }}
153+
154+ - name : Delete temporary branch locally
126155 run : |
127156 echo "Deleting temporary branch"
128157 git branch -D temp
129158
130- - name : Push Cleanup
159+ - name : Delete temporary branch remotely
131160 run : |
132- echo "Cleaning up remote branches "
161+ echo "Deleting temporary branch from remote "
133162 git push origin --delete temp
134163
135164 - name : Echo Cleanup Completed
136- run : echo "Temporary branch has been deleted."
165+ run : echo "Temporary branch has been deleted."
166+
0 commit comments