Welcome to my GitHub Actions demo repository! This project showcases a well-structured Continuous Integration (CI) pipeline using GitHub Actions. Below, I’ll walk you through what this workflow does, how it’s set up, and why I designed it this way—perfect for anyone exploring my GitHub profile to see my skills in action!
This repository contains a GitHub Actions workflow that automates the build and test process for a sample application. It’s a demonstration of how I approach CI pipelines to ensure code quality and reliability in real-world projects.
The workflow is defined in .github/workflows/ci-demo.yml. Here’s what it does:
- Runs on:
- Push events to
mainordevelopbranches - Pull requests targeting the
mainbranch
- Push events to
- Why: This ensures the pipeline runs automatically whenever code is updated or reviewed, catching issues early.
- Runner:
ubuntu-latest(a cost-effective, widely-used Linux environment) - Variables:
ACCESS_ID: A secure credential stored in GitHub SecretsNODE_VERSION: Set to 18 for consistent Node.js builds
- Why: Using secrets keeps sensitive data safe, and version pinning ensures reproducibility.
- Checkout Repository: Pulls the latest code using
actions/checkout@v4. - Setup Node.js: Configures Node.js (v18) using
actions/setup-node@v3. - Install Dependencies: Runs
npm installwith a fallback if nopackage.jsonis found. - Display Access ID: Shows how to securely use environment variables with
ACCESS_ID. - Run Tests: Executes
npm test(with a fallback message if no tests exist). - Debug on Failure: If anything fails, it prints environment details for troubleshooting.
- Why: These steps mimic a real CI process—code retrieval, environment setup, dependency management, testing, and debugging—while staying flexible for minimal setups.
- Automate Processes: Streamline development with CI.
- Handle Security: Use GitHub Secrets for sensitive data.
- Write Maintainable Code: Structure workflows with clear steps and error handling.
- Think Practically: Include fallbacks and debugging to handle edge cases gracefully.