{"id":19920868,"url":"https://github.com/hgschandeepa/nodejs-rest-api-ec2","last_synced_at":"2025-09-19T04:31:41.134Z","repository":{"id":228217233,"uuid":"773347557","full_name":"HGSChandeepa/nodejs-rest-api-EC2","owner":"HGSChandeepa","description":"Auto Deploy Node.js REST API on AWS EC2 | CI/CD Pipeline using GitHub Actions","archived":false,"fork":false,"pushed_at":"2024-03-17T15:32:23.000Z","size":26,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-12T22:06:09.859Z","etag":null,"topics":["aws-ec2","ci-cd","github","github-actions","githubaction-workflow","nginx","pm2"],"latest_commit_sha":null,"homepage":"https://medium.com/@saminchandeepa/auto-deploy-node-js-rest-api-on-aws-ec2-ci-cd-pipeline-using-github-actions-031be66824d1","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HGSChandeepa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-17T12:28:41.000Z","updated_at":"2024-09-30T19:16:49.000Z","dependencies_parsed_at":"2024-03-17T17:49:17.105Z","dependency_job_id":null,"html_url":"https://github.com/HGSChandeepa/nodejs-rest-api-EC2","commit_stats":null,"previous_names":["hgschandeepa/nodejs-rest-api-ec2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HGSChandeepa%2Fnodejs-rest-api-EC2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HGSChandeepa%2Fnodejs-rest-api-EC2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HGSChandeepa%2Fnodejs-rest-api-EC2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HGSChandeepa%2Fnodejs-rest-api-EC2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HGSChandeepa","download_url":"https://codeload.github.com/HGSChandeepa/nodejs-rest-api-EC2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233550327,"owners_count":18692829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-ec2","ci-cd","github","github-actions","githubaction-workflow","nginx","pm2"],"created_at":"2024-11-12T22:06:11.914Z","updated_at":"2025-09-19T04:31:41.120Z","avatar_url":"https://github.com/HGSChandeepa.png","language":"JavaScript","readme":"# Node.js REST API Deployment on AWS EC2 with GitHub Actions CI/CD Pipeline Notes\n\nThis repository demonstrates a streamlined approach to deploying a Node.js REST API on an AWS EC2 instance using GitHub Actions for continuous integration and continuous deployment (CI/CD).\n\n## Overview\n\nIn this project, we utilize GitHub Actions workflows to automate the CI/CD pipeline for deploying changes to our Node.js application on an EC2 instance. The workflow consists of:\n\n- **Continuous Integration (CI):** Automatically building and testing the application on each push to the `main` branch.\n- **Continuous Deployment (CD):** Automatically deploying changes to the EC2 instance upon successful completion of CI.\n\n## Setup Instructions\n\nFollow these steps to set up the deployment pipeline for your Node.js REST API on AWS EC2:\n\n1. **Create an EC2 Instance:**\n   - Create a new EC2 instance in your AWS account or use an existing one.\n   - Generate or use an existing SSH key pair for accessing the instance.\n\n2. **Git Repository Setup:**\n   - Create a new Git repository and push your Node.js code to it.\n\n3. **GitHub Actions Setup:**\n   - Navigate to your repository settings on GitHub and select Actions.\n   - Add a self-hosted runner and follow the setup instructions.\n\n4. **Environment Setup for GitHub Actions:**\n   - Create a `.env` file with your environment variables and add them as secrets in your GitHub repository settings.\n\n5. **CI/CD Workflows:**\n   - Define CI/CD workflows in the `.github/workflows` directory.\n   - Customize workflows to suit your project requirements.\n\n6. **Environment Setup in EC2 Instance:**\n   - Install Node.js and Nginx on your EC2 instance.\n   - Configure Nginx as a reverse proxy for your Node.js application.\n   - Install PM2 to manage your Node.js process.\n\n## Workflow Explanation\n\n- **CI Process:** On each push to the `main` branch, the workflow executes CI tasks such as checking out code, setting up the Node.js environment, installing dependencies, and running tests (if applicable).\n- **CD Process:** Upon successful CI, the workflow triggers CD tasks including SSH into the EC2 instance, pulling the latest changes, restarting the Node.js application, and verifying deployment.\n\n## Directory Structure\n\n- `src/`: Contains the source code for the Node.js application.\n- `.github/workflows/`: Contains CI/CD workflow configuration files.\n- `.env`: Stores environment variables for the application.\n- `server.js`: Entry point for the Node.js application.\n- `package.json`: Dependency configuration for npm.\n\n## Usage\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/HGSChandeepa/nodejs-rest-api-EC2\n   ```\n\n2. Customize the Node.js application code in the `server.js` file according to your requirements.\n\n3. Push changes to the `main` branch. GitHub Actions will automatically trigger the CI/CD pipeline.\n\n## Contributions\n\nContributions to improve this CI/CD setup or add additional features are welcome! Feel free to submit pull requests or open issues.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhgschandeepa%2Fnodejs-rest-api-ec2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhgschandeepa%2Fnodejs-rest-api-ec2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhgschandeepa%2Fnodejs-rest-api-ec2/lists"}