This is a simple demo project showing how to create a GitHub Actions workflow that builds a Docker image and can be triggered manually via the GitHub CLI.
.
├── app.py # Simple Python Hello World app
├── Dockerfile # Docker configuration
├── .github/workflows/docker-build.yml # GitHub Actions workflow
└── README.md # This file
- GitHub CLI - Install from cli.github.com
- Git - For cloning and pushing to GitHub
- GitHub Account - To create the repository
# Create a new repository on GitHub
gh repo create github-actions-docker-demo --public
# Clone the repository
git clone https://github.com/YOUR_USERNAME/github-actions-docker-demo.git
cd github-actions-docker-demo
Copy all the files from this demo project to your repository:
# Add all files
git add .
git commit -m "Initial commit: Add GitHub Actions Docker workflow demo"
git push origin main
You can trigger the workflow manually using the GitHub CLI:
# Basic workflow run
gh workflow run docker-build.yml
# With custom tag
gh workflow run docker-build.yml -f tag=v1.0.0
# Check workflow status
gh run list --workflow=docker-build.yml
To view the workflow logs:
# List recent runs
gh run list --workflow=docker-build.yml
# View logs for the most recent run
gh run view --log
# View logs for a specific run ID
gh run view RUN_ID --log
You can also view the logs in the GitHub web interface:
- Go to your repository on GitHub
- Click on the "Actions" tab
- Click on the "Docker Build Workflow" workflow
- Click on the specific run to see detailed logs
- Manual Trigger: Uses
workflow_dispatch
to allow manual triggering - Docker Build: Builds a Docker image from the Dockerfile
- Container Testing: Runs the container to verify it works
- Build Logs: Shows detailed build output in GitHub Actions interface
- Custom Tags: Allows specifying custom Docker image tags
When you run the workflow, you'll see output like:
🐳 Building Docker image...
✅ Docker image built successfully!
📋 Available Docker images:
🧪 Testing Docker container...
🐳 Hello from Docker!
Current time: 2024-01-15 10:30:45.123456
Python version: 3.11.x
This is a simple demo app for GitHub Actions Docker workflow
Application started successfully!
✅ Container test completed!
📊 Build Summary:
- Image: demo-app:latest
- Build completed at: Mon Jan 15 10:30:45 UTC 2024
- Workflow triggered by: your-username
- Change the app: Edit
app.py
to modify the application - Modify Docker setup: Update
Dockerfile
for different base images or configurations - Extend workflow: Add steps to the
.github/workflows/docker-build.yml
file - Add triggers: Include other triggers like
push
orpull_request
in the workflow
If the workflow fails:
- Check the logs using
gh run view --log
- Verify all files are properly committed to the repository
- Ensure the workflow file is in the correct location:
.github/workflows/docker-build.yml
- Make sure Docker syntax is correct in the Dockerfile