Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

Logs not displaying in github actions

I'm piping logs from AWS Cloudwatch to this github action. However, I have noticed that if I don't open it (clicking the drop down arrow to see the logs from the script) before it starts, the action becomes essentially unviewable. It refuses to open, and I can't see the logs. 

Why is this happening? Should I be doing something different to avoid this? 

 

Thank you.

2 Replies
GitHub Partner
Message 2 of 3

Re: Logs not displaying in github actions

How do you configure the workflow to pipe the logs? Can you share some screenshots for us to better understand your issue? Or can you share us the link to the runs if it is a public repository?

Highlighted
Copilot Lvl 2
Message 3 of 3

Re: Logs not displaying in github actions

Unfortunately it's a private repository, but I can share some of the script.

Context:
I have a github action hit a lambda, which starts an ec2 instance with a previously specified user data script. In this script I'm building a bunch of Docker images that are relevant to my project. The process takes maybe 20 minutes total, and I have this Action in Github polling the logs the whole time. When the user data script is done it is quite easy to view the logs in the action, but while I'm still in the process the browser tab often crashes or becomes unusable.

Sample script:

while [ FINISH_CONDITION ]
do

    LOG_DETAILS=$(aws logs get-log-events \
        --log-group-name docker-ci \
        --log-stream-name ${INSTANCE_ID} \
        --next-token $TOKEN)
    TOKEN=$(echo $LOG_DETAILS | jq '.nextForwardToken' | tr -d '"')
    echo $LOG_DETAILS | jq '.events[].message'

    sleep 30
done

The workflow definition: 

The script above is in "poll-logs.sh"

name: Docker CI

on:
  push:
    tags:
    - '*'

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_DEFAULT_REGION: 'us-east-1'
    steps:
    - name: checkout
      uses: actions/checkout@v1
    - name: install aws cli
      run: sudo apt-get install awscli jq -y
    - name: build docker containers
      run: |
        aws lambda invoke \
        --function-name sample-function-lambda \
        --payload file://dockerfiles/config.json \
        ./output.txt
        INSTANCE_ID=$(cat output.txt | tr -d '"')
        echo "INSTANCE_ID ${INSTANCE_ID}"
        ./.github/poll-logs.sh $INSTANCE_ID


Thank you for your time