Skip to content

Commit 097d3ab

Browse files
committed
Add logOutput variable so output can be used by other actions
1 parent 5ed0126 commit 097d3ab

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 2
5+
indent_size = 4
66
end_of_line = lf
77
charset = utf-8
88
trim_trailing_whitespace = true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ This action is great for executing migrations or other pre/post deployment steps
7979
| --- | --- |
8080
| task-arn | The full ARN for the task that was ran. Will be added as ENV variable. |
8181
| task-id | The ID for the task that was ran. Will be added as ENV variable. |
82+
| log-output | The log output of the task that was ran, if `tail-logs` was set to true. |
8283
<!-- action-docs-outputs -->
8384

8485
<!-- action-docs-runs -->

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ outputs:
5353
description: 'The full ARN for the task that was ran. Will be added as ENV variable.'
5454
task-id:
5555
description: 'The ID for the task that was ran. Will be added as ENV variable.'
56+
log-output:
57+
description: 'The log output of the task that was ran, if `tail-logs` was set to true.'
5658

5759
runs:
5860
using: 'node16'

index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ const main = async () => {
6767

6868
// Get logging configuration
6969
let logFilterStream = null;
70+
let logOutput = null;
71+
7072
if (tailLogs) {
7173
core.debug(`Logging enabled. Getting logConfiguration from TaskDefinition.`)
7274
let taskDef = await ecs.describeTaskDefinition({taskDefinition: taskDefinition}).promise();
@@ -104,7 +106,9 @@ const main = async () => {
104106
});
105107

106108
logFilterStream.on('data', function (eventObject) {
107-
core.info(`${new Date(eventObject.timestamp).toISOString()}: ${eventObject.message}`);
109+
const logLine = `${new Date(eventObject.timestamp).toISOString()}: ${eventObject.message}`
110+
core.info(logLine);
111+
logOutput += logLine + '\n';
108112
});
109113

110114
return true;
@@ -113,6 +117,9 @@ const main = async () => {
113117
}
114118
}
115119

120+
// Set output variable, so it can be used by other actions
121+
core.setOutput('log-output', logOutput);
122+
116123
// Wait for Task to finish
117124
core.debug(`Waiting for task to finish.`);
118125
await ecs.waitFor('tasksStopped', {cluster, tasks: [taskArn]}).promise();

0 commit comments

Comments
 (0)