|
1 | | -## CI-CD-Integration-IN-NodeJS |
| 1 | +# 🚀 CI/CD Integration in Node.js with GitHub Actions & VPS (or AWS EC2) |
| 2 | + |
| 3 | +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**. |
| 4 | +We will also learn how to deploy our Node.js application on a VPS server or AWS EC2 instance using a **CI/CD pipeline**. |
| 5 | + |
| 6 | +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. |
| 7 | +I created this repository as part of my learning journey, so feel free to explore and adapt it for your own CI/CD needs. |
| 8 | + |
| 9 | +## 📚 Prerequisites |
| 10 | + |
| 11 | +Make sure you know the basics of: |
| 12 | + |
| 13 | +- **Node.js** & **Express.js** |
| 14 | +- **Git** & **GitHub** |
| 15 | +- **AWS EC2** or any **VPS server** |
| 16 | +- CI/CD fundamentals |
| 17 | +- **GitHub Actions** |
| 18 | +- **SSH** |
| 19 | +- **Nginx** server setup |
| 20 | +- **PM2** process manager |
| 21 | +- **MongoDB** (if needed) |
| 22 | +- Basic **environment variables** usage |
| 23 | +- Basic **Linux** commands |
| 24 | +- Basic **terminal** usage |
| 25 | +- Basic **networking** concepts |
| 26 | +- Basic **firewall** setup |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## 🛠️ Setup This Project Locally |
| 31 | + |
| 32 | +### 1. Clone the repository |
| 33 | + |
| 34 | +```bash |
| 35 | +git clone https://github.com/vikashkrdeveloper/CI-CD-Integration-IN-NodeJS.git && cd CI-CD-Integration-IN-NodeJS |
| 36 | +``` |
| 37 | + |
| 38 | +### 2. Install dependencies |
| 39 | + |
| 40 | +```bash |
| 41 | +npm install |
| 42 | +``` |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## ▶️ Run The Application Locally |
| 47 | + |
| 48 | +```bash |
| 49 | +npm start |
| 50 | +``` |
| 51 | + |
| 52 | +Open your browser and go to: |
| 53 | +👉 [http://localhost:3000](http://localhost:3000) |
| 54 | +You should see: **Hello CI/CD World!** |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## 🌐 Test The API |
| 59 | + |
| 60 | +### Using `curl` |
| 61 | + |
| 62 | +```bash |
| 63 | +curl -X GET http://localhost:3000/ |
| 64 | +``` |
| 65 | + |
| 66 | +### Using browser |
| 67 | + |
| 68 | +👉 [http://localhost:3000/](http://localhost:3000/) |
| 69 | + |
| 70 | +### Using Postman |
| 71 | + |
| 72 | +Send a `GET` request to `http://localhost:3000/` |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## 🚀 Steps to Integrate CI/CD with GitHub Actions + VPS (or EC2) |
| 77 | + |
| 78 | +1. Create your **Node.js** application |
| 79 | +2. Push the project to **GitHub** |
| 80 | +3. Set up your **VPS** or **AWS EC2** instance |
| 81 | +4. Install on your server: |
| 82 | + - Node.js |
| 83 | + - Nginx |
| 84 | + - PM2 |
| 85 | + - MongoDB (if needed) |
| 86 | +5. Set up **SSH keys** between GitHub Actions and your server |
| 87 | +6. Create a **GitHub Actions workflow** file (`.github/workflows/main.yml`) |
| 88 | +7. Configure the pipeline to: |
| 89 | + - Install dependencies |
| 90 | + - Run tests |
| 91 | + - SSH into server |
| 92 | + - Pull latest code |
| 93 | + - Restart app with PM2 |
| 94 | +8. Test by pushing a commit — CI/CD should trigger 🚀 |
| 95 | +9. Celebrate! Your Node.js app is now automatically deployed! 🎉 |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## 🏅 Pro Tips |
| 100 | + |
| 101 | +- 🔒 Always use environment variables for sensitive data. |
| 102 | +- 🔥 Use `pm2 status` to monitor your Node.js app in production. |
| 103 | +- 🌐 Set up **Nginx reverse proxy** for serving your app securely. |
| 104 | +- ⚡ Use **fail2ban** or **firewalls** to protect your VPS. |
| 105 | +- 🕵️ Regularly check `pm2 logs` for debugging. |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## ❤️ Contributing |
| 110 | + |
| 111 | +Want to improve this guide? |
| 112 | +Feel free to fork this repo, submit pull requests, or open issues. Contributions are welcome! |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## 📄 License |
| 117 | + |
| 118 | +This project is licensed under the **MIT License** — you are free to use and modify it. |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## 📸 Screenshots |
| 123 | + |
| 124 | +Add any relevant screenshots here! 📸 (Optional) |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +## 📞 Contact |
| 129 | + |
| 130 | +- **Name**: Vikash Kumar |
| 131 | +- **Location**: India |
| 132 | +- **What's App**: [+91 7352514546](https://wa.me/917352514546/?text=Hello%20Vikash%2C%20I%20need%20help%20with%20CI/CD%20integration%20in%20Node.js.) |
| 133 | + |
| 134 | +- **LinkedIn**: [Vikash Kumar](https://www.linkedin.com/in/vikashkrdeveloper/) |
| 135 | +- **GitHub**: [Vikash Kumar](https://www.github.com/vikashkrdeveloper) |
| 136 | +- **Twitter**: [@vikashkrdeveloper](https://twitter.com/vikashkrdeveloper) |
| 137 | +- **Instagram**: [@vikashkrdeveloper](https://www.instagram.com/vikashkrdeveloper/) |
| 138 | +- **Portfolio**: [vikashkrdeveloper](https://vikashkrdeveloper.github.io/) |
| 139 | +- **Telegram**: [@vikashkrdeveloper](https://t.me/vikashkrdeveloper) |
| 140 | +- **YouTube**: [Vikash Kumar](https://www.youtube.com/@vikashkrdeveloper) |
| 141 | + |
| 142 | +## 📝 Author |
| 143 | + |
| 144 | +Developed by [Vikash Kumar](https://github.com/vikashkrdeveloper) |
| 145 | +Let’s build cool things together! 🚀 |
| 146 | + |
| 147 | +Ab tumhara kaam pura ho gaya, bhai! 😊 If facing any issues, please check the **Issues** tab or create a new issue. |
| 148 | + |
| 149 | +Feel free to reach out if you have any questions or need help with CI/CD integration in Node.js. |
| 150 | +Happy coding! 💻 |
0 commit comments