Skip to content

vikashkrdeveloper/CI-CD-Integration-IN-NodeJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ CI/CD Integration in Node.js with GitHub Actions & VPS (or AWS EC2)

In this repository, we will learn how to integrate CI/CD in a Node.js application using GitHub Actions and a VPS server or AWS EC2 instance.
We will also learn how to deploy our Node.js application on a VPS server or AWS EC2 instance using a CI/CD pipeline.

This is a step-by-step guide designed for learning and practicing CI/CD integration in real-world Node.js projects using GitHub Actions and remote servers.
I created this repository as part of my learning journey, so feel free to explore and adapt it for your own CI/CD needs.

πŸ“š Prerequisites

Make sure you know the basics of:

  • Node.js & Express.js
  • Git & GitHub
  • AWS EC2 or any VPS server
  • CI/CD fundamentals
  • GitHub Actions
  • SSH
  • Nginx server setup
  • PM2 process manager
  • MongoDB (if needed)
  • Basic environment variables usage
  • Basic Linux commands
  • Basic terminal usage
  • Basic networking concepts
  • Basic firewall setup

πŸ› οΈ Setup This Project Locally

1. Clone the repository

git clone https://github.com/vikashkrdeveloper/CI-CD-Integration-IN-NodeJS.git && cd CI-CD-Integration-IN-NodeJS

2. Install dependencies

npm install

▢️ Run The Application Locally

npm start

Open your browser and go to:
πŸ‘‰ http://localhost:3000
You should see: Hello CI/CD World!


🌐 Test The API

Using curl

curl -X GET http://localhost:3000/

Using browser

πŸ‘‰ http://localhost:3000/

Using Postman

Send a GET request to http://localhost:3000/


πŸš€ Steps to Integrate CI/CD with GitHub Actions + VPS (or EC2)

  1. Create your Node.js application
  2. Push the project to GitHub
  3. Set up your VPS or AWS EC2 instance
  4. Install on your server:
    • Node.js
    • Nginx
    • PM2
    • MongoDB (if needed)
  5. Set up SSH keys between GitHub Actions and your server
  6. Create a GitHub Actions workflow file (.github/workflows/main.yml)
  7. Configure the pipeline to:
    • Install dependencies
    • Run tests
    • SSH into server
    • Pull latest code
    • Restart app with PM2
  8. Test by pushing a commit β€” CI/CD should trigger πŸš€
  9. Celebrate! Your Node.js app is now automatically deployed! πŸŽ‰

πŸ… Pro Tips

  • πŸ”’ Always use environment variables for sensitive data.
  • πŸ”₯ Use pm2 status to monitor your Node.js app in production.
  • 🌐 Set up Nginx reverse proxy for serving your app securely.
  • ⚑ Use fail2ban or firewalls to protect your VPS.
  • πŸ•΅οΈ Regularly check pm2 logs for debugging.

❀️ Contributing

Want to improve this guide?
Feel free to fork this repo, submit pull requests, or open issues. Contributions are welcome!


πŸ“„ License

This project is licensed under the MIT License β€” you are free to use and modify it.


πŸ“Έ Screenshots

Add any relevant screenshots here! πŸ“Έ (Optional)


πŸ“ž Contact

πŸ“ Author

Developed by Vikash Kumar
Let’s build cool things together! πŸš€

Ab tumhara kaam pura ho gaya, bhai! 😊 If facing any issues, please check the Issues tab or create a new issue.

Feel free to reach out if you have any questions or need help with CI/CD integration in Node.js. Happy coding! πŸ’»

About

Testing CI/CD pipelines in Node.js πŸš€. Automating build, test, and deploy with simple workflows. βš™οΈ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published