This project demonstrates a robust Continuous Integration and Continuous Deployment (CI/CD) pipeline setup using GitHub Actions.
CI/CD which stands for Continuous Integration and Continuous Delivery/Deployment is a set of practices and tools used in software development to improve the speed and quality of code delivery.
Continuous Integration (CI): Developers frequently merge their code changes into a central repository where Automated builds and tests are run.
This helps catch and fix integration issues early.
Continuous Delivery (CD): This process automatically prepare code changes for release to production by ensuring that the code is always in a deployable state.
It automatically deploys every change that passes all stages of the production pipeline.
And no human intervention is required.
The Key benefits of CI/CD:
- Improved code quality and reliability
- Reduced manual errors
- Increased developer productivity
- More frequent releases and faster feedback.
This project is designed for developers who want to automate their build, test, and deployment processes for a Node.js application.
The pipeline is configured to trigger on pushes to the main branch, ensuring that every code change is automatically built, tested, and deployed to a staging environment.
Prerequisites:
- A GitHub account
- A Docker Hub account
- Node.js and npm installed on your local machine
- Basic knowledge of Node.js, Docker, and YAML
Key Features:
-
Automated Build Process:
- Utilizes Docker to build the application
- Pushes the Docker image to Docker Hub for easy distribution
-
Automated Testing:
- Integrates Jest for running unit tests
- Configures the pipeline to run tests automatically on each push
-
Automated Deployment:
- Deploys successful builds to a staging environment.
- Easily customizable for different deployment targets.
-
GitHub Actions Workflow:
- Uses GitHub Actions for CI/CD, providing a free and powerful automation tool
- Clearly defined workflow stages: build, test, and deploy stages.
-
Secure Credential Management:
- Utilizes GitHub Secrets for storing sensitive information like Docker Hub credentials
To get started with this project:
- Clone the repository:
git clone https://github.com/Lumen-jane/CI-CD-for-my-Resume.git
cd CI-CD-for-my-Resume
- Install dependencies:
npm install
This will install all the key dependencies.
- Set up GitHub Secrets: You need to integrate your own Docker Hub accounts with the CI/CD pipeline, this will allow automated building and pushing of Docker images as part of the deployment process.
- In your GitHub repository, go to Settings > Secrets and variables > Actions
Add the following secrets:
-
DOCKER_USERNAME
: Your Docker Hub username -
DOCKER_PASSWORD
: Your Docker Hub password
-
-
Customize your workflow:
- Open
.github/workflows/maryjane_pipeline.yml
- Modify the Docker image name and deployment steps as needed
- Open
Push changes to the main branch to trigger the workflow:
git add .
git commit -m "Customize CI/CD pipeline"
git push origin main
- Monitor the workflow:
- Go to the "Actions" tab in your GitHub repository to see the workflow in action.
Customization Options:
- Dockerfile: You can Modify the
Dockerfile
in the root directory to change how your application is containerized. - Tests: You can Add or modify your app.test.js, mine is just a placeholder.
- Deployment: Update the deployment step in the workflow file to match your staging environment setup.
- Dependencies: You need to add or modify dependencies, update the
package.json
file if you want to and runnpm install
to install dependencies as they are not included in the repository due to.gitignore
settings.
Conclusion:
This project provides a solid foundation for implementing CI/CD in your Node.js applications. By cloning this repository, you save time setting up the pipeline from scratch and can focus on customizing it to your specific needs.
Please Feel free to contribute, raise issues, or suggest improvements to make this CI/CD pipeline even better!
Top comments (0)