@@ -17,10 +17,10 @@ async function runWorkflowAsync() {
17
17
) ;
18
18
const containerName = core . getInput ( 'azure-storage-container-name' ) ;
19
19
const containerClient = blobServiceClient . getContainerClient ( containerName ) ;
20
- const triggerFileId = uuidv4 ( ) ;
21
- const blobName = `new/${ triggerFileId } .json` ;
22
- const failedBlobPrefix = `failed/${ triggerFileId } ` ;
23
- const succeededBlobPrefix = `succeeded/${ triggerFileId } ` ;
20
+ const clientWorkflowId = uuidv4 ( ) ;
21
+ const blobName = `new/${ clientWorkflowId } .json` ;
22
+ const failedBlobPrefix = `failed/${ clientWorkflowId } ` ;
23
+ const succeededBlobPrefix = `succeeded/${ clientWorkflowId } ` ;
24
24
const blockBlobClient = containerClient . getBlockBlobClient ( blobName ) ;
25
25
26
26
const data = {
@@ -31,10 +31,11 @@ async function runWorkflowAsync() {
31
31
} ;
32
32
33
33
const jsonData = JSON . stringify ( data ) ;
34
+ const startTime = Date . now ( ) ;
34
35
35
36
try {
36
37
await blockBlobClient . upload ( jsonData , jsonData . length ) ;
37
- console . log ( `Blob was uploaded successfully. URL : ${ blockBlobClient . url } ` ) ;
38
+ console . log ( `Trigger file created : ${ blockBlobClient . url } ` ) ;
38
39
} catch ( error ) {
39
40
core . setFailed ( `Error uploading blob: ${ error . message } ` ) ;
40
41
return ;
@@ -45,23 +46,19 @@ async function runWorkflowAsync() {
45
46
// Loop until the workflow is done
46
47
while ( ! isDone ) {
47
48
try {
48
- for await ( const blob of containerClient . listBlobsFlat ( { prefix : succeededBlobPrefix } ) ) {
49
- if ( blob . name . startsWith ( succeededBlobPrefix ) ) {
50
- console . log ( 'Workflow succeeded.' ) ;
51
- core . setOutput ( "status" , "succeeded" ) ;
52
- isDone = true
53
- break ;
54
- }
49
+ for await ( const { } of containerClient . listBlobsFlat ( { prefix : succeededBlobPrefix } ) ) {
50
+ console . log ( 'Workflow succeeded.' ) ;
51
+ core . setOutput ( "status" , "succeeded" ) ;
52
+ isDone = true
53
+ break ;
55
54
}
56
55
57
56
if ( isDone ) break ;
58
57
59
- for await ( const blob of containerClient . listBlobsFlat ( { prefix : failedBlobPrefix } ) ) {
60
- if ( blob . name . startsWith ( failedBlobPrefix ) ) {
61
- core . setFailed ( 'Workflow failed.' ) ;
62
- isDone = true ;
63
- break ;
64
- }
58
+ for await ( const { } of containerClient . listBlobsFlat ( { prefix : failedBlobPrefix } ) ) {
59
+ core . setFailed ( 'Workflow failed.' ) ;
60
+ isDone = true ;
61
+ break ;
65
62
}
66
63
67
64
if ( isDone ) break ;
@@ -72,6 +69,13 @@ async function runWorkflowAsync() {
72
69
await new Promise ( resolve => setTimeout ( resolve , 30000 ) ) ; // wait 30 seconds before checking again
73
70
}
74
71
72
+ const endTime = Date . now ( ) ;
73
+ const duration = ( endTime - startTime ) / 1000 ; // Duration in seconds
74
+ const hours = Math . floor ( duration / 3600 ) ; // Calculate hours
75
+ const minutes = Math . floor ( ( duration % 3600 ) / 60 ) ; // Calculate minutes
76
+ const seconds = Math . floor ( duration % 60 ) ; // Calculate seconds
77
+
78
+ console . log ( `Workflow completed in ${ hours } h ${ minutes } m ${ seconds } s` ) ;
75
79
}
76
80
77
81
async function run ( ) {
0 commit comments