Description
First, thanks for all your updates to this action and your blog post, it was a big help to me! I'm not sure if this is the best place to talk about future ideas, but one idea I had was it would be really cool if the action could output the cloudwatch logs for the task when the task finishes. This is especially helpful if the task fails.
If anyone needs something like this today, I was able to implement this using another step like so. It will run even if the run-task step fails:
- name: Fetch log output from run task
if: always()
run: |
task_arn=${{ steps.run-task.outputs.task-arn }}
if [ -n "$task_arn" ]; then
#remove [] around task arn
task_arn=`echo $task_arn | sed 's/[][]//g'`
task_id=${task_arn##*/}
aws logs get-log-events --log-group-name $LOG_GROUP_NAME --log-stream-name $LOG_PREFIX/$task_id --output text --start-from-head || exit 0
else
echo 'No logs available since run task did not run'
fi
Perhaps another idea that would avoid cloudwatch logs altogether would be an action that can:
- Launch a task using run-task with
--enable-execute-command
and a container command like "sleep 3600" - Wait until the task starts
- Run ECS's
execute-command
with the task id in step 1. I believe this should return the output from the command immediately to github actions. This does require the SSM Session Manager plugin though. - Once execute-command completes, then stop the task.
I believe this way we could get the output of the command directly to github actions in real time as the command is running in the task. Unfortunately, there's no action I could find that can do ECS's execute-command
yet, but hopefully some day. If I get some time, I may try this out with just aws cli commands. But for now, the step I posted above is working great to see logs from my task in Github actions.