Skip to content

Refactor script to dynamically find container names. #42

Refactor script to dynamically find container names.

Refactor script to dynamically find container names. #42

name: Build Docker and Capture Python Logs
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Docker Image
run: docker build app/. -t python-app
- name: Run Docker Container
run: |
docker run --name python-app python-app &
APP_PID=$!
sleep 1 # Adjust sleep as necessary to allow your application to initialize and generate logs
docker stop python-app
wait $APP_PID
cat app_stdout.txt
cat app_stderr.txt >&2 # Direct stderr to the workflow's stderr to highlight errors
- name: Capture Container Logs
run: docker logs python-app > container_logs.txt
- name: Upload Container Logs as Artifact
uses: actions/upload-artifact@v2
with:
name: py-container-logs
path: py-container_logs.txt