@@ -28,11 +28,14 @@ export class FinalizeDeploymentV2Service extends BaseService {
28
28
friendlyId : id ,
29
29
environmentId : authenticatedEnv . id ,
30
30
} ,
31
- include : {
31
+ select : {
32
+ status : true ,
33
+ id : true ,
34
+ version : true ,
35
+ externalBuildData : true ,
32
36
environment : true ,
33
37
worker : {
34
- include : {
35
- tasks : true ,
38
+ select : {
36
39
project : true ,
37
40
} ,
38
41
} ,
@@ -84,6 +87,14 @@ export class FinalizeDeploymentV2Service extends BaseService {
84
87
throw new ServiceValidationError ( "Missing depot token" ) ;
85
88
}
86
89
90
+ const digest = extractImageDigest ( body . imageReference ) ;
91
+
92
+ logger . debug ( "Pushing image to registry" , {
93
+ id,
94
+ deployment,
95
+ digest,
96
+ } ) ;
97
+
87
98
const pushResult = await executePushToRegistry (
88
99
{
89
100
depot : {
@@ -110,17 +121,39 @@ export class FinalizeDeploymentV2Service extends BaseService {
110
121
throw new ServiceValidationError ( pushResult . error ) ;
111
122
}
112
123
124
+ const fullImage = digest ? `${ pushResult . image } @${ digest } ` : pushResult . image ;
125
+
126
+ logger . debug ( "Image pushed to registry" , {
127
+ id,
128
+ deployment,
129
+ body,
130
+ fullImage,
131
+ } ) ;
132
+
113
133
const finalizeService = new FinalizeDeploymentService ( ) ;
114
134
115
135
const finalizedDeployment = await finalizeService . call ( authenticatedEnv , id , {
116
- imageReference : pushResult . image ,
136
+ imageReference : fullImage ,
117
137
skipRegistryProxy : true ,
118
138
} ) ;
119
139
120
140
return finalizedDeployment ;
121
141
}
122
142
}
123
143
144
+ // Extracts the sha256 digest from an image reference
145
+ // For example the image ref "registry.depot.dev/gn57tl6chn:8qfjm8w83w@sha256:aa6fd2bdcbbd611556747e72d0b57797f03aa9b39dc910befc83eea2b08a5b85"
146
+ // would return "sha256:aa6fd2bdcbbd611556747e72d0b57797f03aa9b39dc910befc83eea2b08a5b85"
147
+ function extractImageDigest ( image : string ) {
148
+ const digestIndex = image . lastIndexOf ( "@" ) ;
149
+
150
+ if ( digestIndex === - 1 ) {
151
+ return ;
152
+ }
153
+
154
+ return image . substring ( digestIndex + 1 ) ;
155
+ }
156
+
124
157
type ExecutePushToRegistryOptions = {
125
158
depot : {
126
159
buildId : string ;
0 commit comments