File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 4545 type=sha,prefix={{branch}}-,format=short
4646 type=semver,pattern={{version}}
4747
48+ - name : Check if image exists
49+ id : check
50+ if : github.event_name != 'pull_request'
51+ continue-on-error : true
52+ run : |
53+ TAGS="${{ steps.meta.outputs.tags }}"
54+ IMAGE_EXISTS=false
55+
56+ for TAG in $TAGS; do
57+ echo "Checking if image exists: $TAG"
58+ if docker manifest inspect $TAG > /dev/null 2>&1; then
59+ echo "Image already exists: $TAG"
60+ IMAGE_EXISTS=true
61+ else
62+ echo "Image does not exist: $TAG"
63+ IMAGE_EXISTS=false
64+ break
65+ fi
66+ done
67+
68+ echo "should_push=$([[ "$IMAGE_EXISTS" == "false" ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
69+
4870 - name : Build and push Docker image
71+ if : github.event_name == 'pull_request' || steps.check.outputs.should_push == 'true'
4972 uses : docker/build-push-action@v6
5073 with :
5174 context : .
5578 cache-from : type=gha
5679 cache-to : type=gha,mode=max
5780 platforms : linux/amd64,linux/arm64
81+
82+ - name : Image push skipped
83+ if : github.event_name != 'pull_request' && steps.check.outputs.should_push != 'true'
84+ run : |
85+ echo "All image tags already exist in registry. Skipping build and push."
You can’t perform that action at this time.
0 commit comments