8888 password : ${{ inputs.registry_password }}
8989
9090 - name : Build
91+ id : build
9192 uses : docker/build-push-action@v6
9293 with :
9394 context : ${{ inputs.distribution }}
9798 tags : ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
9899 cache-from : type=gha
99100 cache-to : type=gha,mode=max
101+ env :
102+ BUILDKIT_PROGRESS : plain
103+
104+ - name : Capture build logs on failure
105+ shell : bash
106+ if : failure() && steps.build.outcome == 'failure'
107+ run : |
108+ mkdir -p /tmp/build-logs
109+
110+ echo "Build failed for ${{ inputs.distribution }} on ${{ inputs.platform }}"
111+ echo "Capturing detailed logs for troubleshooting..."
112+
113+ # Get docker history for the built image (might not exist if build failed early)
114+ docker history ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-history.log 2>&1 || echo "Failed to get image history"
115+
116+ # Get docker inspect output (might not exist if build failed early)
117+ docker inspect ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-inspect.json 2>&1 || echo "Failed to inspect image"
118+
119+ # Get docker build cache info
120+ docker buildx du > /tmp/build-logs/buildx-du.log 2>&1 || echo "Failed to get build cache info"
121+
122+ # Get system info
123+ uname -a > /tmp/build-logs/system-info.log 2>&1
124+ docker info > /tmp/build-logs/docker-info.log 2>&1
125+
126+ # Create a summary file
127+ {
128+ echo "Build failure summary for ${{ inputs.distribution }} on ${{ inputs.platform }}"
129+ echo "Date: $(date)"
130+ echo "GitHub SHA: ${{ github.sha }}"
131+ echo "Platform: ${{ steps.platform.outputs.display_name }}"
132+ echo "Distribution: ${{ inputs.distribution }}"
133+ } > /tmp/build-logs/failure-summary.txt
134+
135+ # Try to extract error information from the build logs
136+ echo "Analyzing build failure..."
137+
138+ # Check for common error patterns
139+ if docker buildx build --no-cache ${{ inputs.distribution }} --platform=${{ inputs.platform }} 2>&1 | tee /tmp/build-logs/build-error.log | grep -q "ERROR"; then
140+ echo "Found ERROR in build output"
141+ grep -A 10 -B 5 "ERROR" /tmp/build-logs/build-error.log > /tmp/build-logs/error-context.log || true
142+ fi
143+
144+ echo "Log capture complete"
145+
146+ - name : Upload build failure logs
147+ if : failure() && steps.build.outcome == 'failure'
148+ uses : actions/upload-artifact@v4
149+ with :
150+ name : build-failure-${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}
151+ path : /tmp/build-logs/
152+ retention-days : 30
153+ if-no-files-found : warn
100154
101155 - name : Save image
102156 shell : bash
@@ -203,13 +257,3 @@ runs:
203257 echo "ReJSON test failed: expected 'allkeys-lru', got $result"
204258 exit 1
205259 fi
206-
207- - name : Push image
208- uses : docker/build-push-action@v6
209- if : ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64"]'), steps.platform.outputs.display_name) }}
210- with :
211- context : ${{ inputs.distribution }}
212- push : true
213- tags : ${{ inputs.registry_repository }}:${{ github.sha }}-${{ inputs.distribution }}
214- cache-from : type=gha
215- cache-to : type=gha,mode=max
0 commit comments