9797 steps :
9898 - uses : actions/checkout@v4
9999 with :
100- fetch-depth : 0 # Full history fetch karo for clean git operations
100+ token : ${{ secrets.GITHUB_TOKEN }}
101+ fetch-depth : 0
101102
102103 # Create build directory
103104 - name : Create build directory
@@ -132,36 +133,50 @@ jobs:
132133 path : build-temp/
133134 continue-on-error : false
134135
135- # Move files to build directory (artifacts download with nested folder structure)
136+ # Move files to build directory
136137 - name : Organize binaries
137138 run : |
138- # List kya download hua
139139 echo "Downloaded files:"
140140 find build-temp/ -type f
141141
142- # Sab files ko build/ mein move karo
142+ # Copy all binaries to build folder
143143 find build-temp/ -type f -name "cmdo*" -exec cp {} build/ \;
144144
145- # Verify
146145 echo "Final build directory:"
147146 ls -lh build/
148147
149- # Commit aur push - ek saath saari files
148+ # Commit aur push - proper way
150149 - name : Commit and push all binaries
151150 run : |
151+ # Git config
152152 git config --local user.email "github-actions[bot]@users.noreply.github.com"
153153 git config --local user.name "github-actions[bot]"
154154
155- # Latest changes pull karo
156- git pull origin main --rebase
155+ # Pehle latest changes pull karo (before any staging)
156+ git pull origin main
157157
158- # Build folder add karo
158+ # Ab files add karo
159159 git add build/
160160
161- # Check if there are changes
161+ # Check if there are changes to commit
162162 if git diff --staged --quiet; then
163163 echo "No changes to commit"
164164 else
165+ echo "Committing changes..."
165166 git commit -m "Build: Update all binaries [skip ci]"
166- git push origin main
167+
168+ # Push with retry logic (in case of race conditions)
169+ for i in {1..3}; do
170+ if git push origin main; then
171+ echo "Push successful!"
172+ exit 0
173+ else
174+ echo "Push failed, retrying... ($i/3)"
175+ git pull origin main --rebase
176+ sleep 2
177+ fi
178+ done
179+
180+ echo "Failed to push after 3 attempts"
181+ exit 1
167182 fi
0 commit comments