5
5
"encoding/json"
6
6
"errors"
7
7
"fmt"
8
+ "os"
8
9
"strings"
9
10
"time"
10
11
@@ -191,18 +192,6 @@ func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.De
191
192
deployRequest .ID = deployStatus .GetRequest ().GetID ()
192
193
telemetry .AddDeploymentRequestSpanAttributes (span , deployStatus .GetRequest ())
193
194
telemetry .AddDeploymentRequestSpanAttributes (requestSpan , deployStatus .GetRequest ())
194
- traceID := telemetry .TraceID (requestContext )
195
-
196
- urlPrefix := "https://" + strings .Split (cfg .DeployServerURL , ":" )[0 ]
197
- log .Infof ("Deployment information:" )
198
- log .Infof ("---" )
199
- log .Infof ("id...........: %s" , deployRequest .GetID ())
200
- if len (traceID ) > 0 {
201
- log .Infof ("tracing......: %s" , cfg .TracingDashboardURL + traceID )
202
- }
203
- log .Infof ("debug logs...: %s" , logproxy .MakeURL (urlPrefix , deployRequest .GetID (), deployRequest .GetTime ().AsTime (), deployRequest .Cluster ))
204
- log .Infof ("deadline.....: %s" , deployRequest .GetDeadline ().AsTime ().Local ())
205
- log .Infof ("---" )
206
195
207
196
return nil
208
197
}
@@ -217,12 +206,48 @@ func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.De
217
206
return err
218
207
}
219
208
209
+ traceID := telemetry .TraceID (ctx )
210
+
211
+ // Print information to standard output
212
+ urlPrefix := "https://" + strings .Split (cfg .DeployServerURL , ":" )[0 ]
213
+ log .Infof ("Deployment information:" )
214
+ log .Infof ("---" )
215
+ log .Infof ("id...........: %s" , deployRequest .GetID ())
216
+ log .Infof ("tracing......: %s" , cfg .TracingDashboardURL + traceID )
217
+ log .Infof ("debug logs...: %s" , logproxy .MakeURL (urlPrefix , deployRequest .GetID (), deployRequest .GetTime ().AsTime (), deployRequest .Cluster ))
218
+ log .Infof ("deadline.....: %s" , deployRequest .GetDeadline ().AsTime ().Local ())
219
+ log .Infof ("---" )
220
+
221
+ // If running in GitHub actions, print a markdown summary
222
+ summaryFile , err := os .OpenFile (os .Getenv ("GITHUB_STEP_SUMMARY" ), os .O_APPEND | os .O_WRONLY , 0644 )
223
+ summary := func (format string , a ... any ) {
224
+ if summaryFile == nil {
225
+ return
226
+ }
227
+ _ , _ = fmt .Fprintf (summaryFile , format + "\n " , a ... )
228
+ }
229
+ finalStatus := func (st * pb.DeploymentStatus ) {
230
+ summary ("* Finished at: %s" , st .Timestamp ())
231
+ summary ("%c Final status: *%s* / %s" , deployStatus .GetState ().StatusEmoji (), deployStatus .GetState (), deployStatus .GetMessage ())
232
+ }
233
+ if err == nil {
234
+ defer summaryFile .Close ()
235
+ }
236
+
237
+ summary ("# 🚀 NAIS deploy" )
238
+ summary ("* Detailed trace: [%s](%s)" , traceID , cfg .TracingDashboardURL + traceID )
239
+ summary ("* Request ID: %s" , deployRequest .GetID ())
240
+ summary ("* Started at: %s" , time .Now ().Local ())
241
+ summary ("* Deadline: %s" , deployRequest .GetDeadline ().AsTime ().Local ())
242
+
220
243
if deployStatus .GetState ().Finished () {
244
+ finalStatus (deployStatus )
221
245
logDeployStatus (deployStatus )
222
246
return ErrorStatus (deployStatus )
223
247
}
224
248
225
249
if ! cfg .Wait {
250
+ finalStatus (deployStatus )
226
251
logDeployStatus (deployStatus )
227
252
return nil
228
253
}
@@ -243,6 +268,7 @@ func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.De
243
268
return err
244
269
})
245
270
if err != nil {
271
+ summary ("❌ lost connection to NAIS deploy" , deployStatus .GetState (), deployStatus .GetMessage ())
246
272
return ErrorWrap (ExitUnavailable , err )
247
273
}
248
274
@@ -254,6 +280,7 @@ func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.De
254
280
log .Warnf (formatGrpcError (err ))
255
281
break
256
282
} else {
283
+ summary ("❌ lost connection to NAIS deploy" , deployStatus .GetState (), deployStatus .GetMessage ())
257
284
return Errorf (ExitUnavailable , formatGrpcError (err ))
258
285
}
259
286
}
@@ -262,14 +289,17 @@ func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.De
262
289
log .Warnf ("NAIS deploy has been restarted. Re-sending deployment request..." )
263
290
err = sendDeploymentRequest ()
264
291
if err != nil {
292
+ summary ("❌ lost connection to NAIS deploy" , deployStatus .GetState (), deployStatus .GetMessage ())
265
293
return err
266
294
}
267
295
} else if deployStatus .GetState ().Finished () {
296
+ finalStatus (deployStatus )
268
297
return ErrorStatus (deployStatus )
269
298
}
270
299
}
271
300
}
272
301
302
+ summary ("❌ timeout" , deployStatus .GetState (), deployStatus .GetMessage ())
273
303
return Errorf (ExitTimeout , "deployment timed out: %w" , ctx .Err ())
274
304
}
275
305
0 commit comments