try again yo #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test CloudWatch Logging | |
on: | |
push: | |
branches: | |
- grafana | |
jobs: | |
log: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create a log stream on AWS CloudWatch | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
run: | | |
TIMESTAMP=$(date +%s000) | |
echo "LOG_STREAM_NAME=javascript-$TIMESTAMP" >> $GITHUB_ENV | |
aws logs create-log-stream --log-group-name "test-results-board" --log-stream-name "javascript-$TIMESTAMP" | |
- name: Send logs to AWS CloudWatch | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
run: | | |
TIMESTAMP=$(date +%s000) | |
LOG_EVENT_JSON=$(jq -n --arg ts "$TIMESTAMP" \ | |
--arg app "complete" \ | |
--arg platform "react" \ | |
--arg run_type "commitly" \ | |
--argjson exec_time 0 \ | |
--argjson passed 0 \ | |
--argjson failed 0 \ | |
--arg link "https://github.com/corbado/javascript/actions/runs/${GITHUB_RUN_ID}" \ | |
'[{timestamp: ($ts|tonumber), message: {application: $app, platform: $platform, run_type: $run_type, execution_time: $exec_time, passed: $passed, failed: $failed, link: $link}}] | .[0].message | @json') | |
FINAL_LOG_EVENT_JSON=$(jq -n --arg ts "$TIMESTAMP" --arg msg "$LOG_EVENT_JSON" '[{timestamp: ($ts|tonumber), message: $msg}]') | |
aws logs put-log-events --log-group-name "test-results-board" --log-stream-name "$LOG_STREAM_NAME" --log-events "$FINAL_LOG_EVENT_JSON" |