You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-6Lines changed: 41 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,14 @@ This project is a demonstration of how to set up a full CI/CD pipeline for a Nod
16
16
17
17
## CI/CD Pipeline
18
18
19
-
The CI/CD pipeline is split into two workflows: `ci-cd.yml` for Continuous Integration and `release.yml` for Continuous Deployment.
19
+
The CI/CD pipeline is split into two workflows: `ci.yml` for Continuous Integration and `release.yml` for Continuous Deployment.
20
20
21
-
### `ci-cd.yml` - Continuous Integration
21
+
### `ci.yml` - Continuous Integration
22
22
23
23
This workflow runs on every push to the `main`, `development`, and `feature/*` branches. It consists of two jobs:
24
24
25
25
1.**`build-and-test`:** This job builds the application and runs the test suite.
26
-
2.**`bump-version`:** This job runs only on the `main` branch after the `build-and-test` job succeeds. It automatically bumps the patch version of the application and creates a new Git tag (e.g., `v1.0.1`).
26
+
2.**`bump-version`:** This job runs only on the `main` branch after the `build-and-test` job succeeds. It automatically bumps the patch version of the application and creates a new Git tag (e.g., `v1.0.1`). The tagging step uses a Personal Access Token stored as `REPO_ACCESS_TOKEN`.
27
27
28
28
### `release.yml` - Continuous Deployment
29
29
@@ -40,7 +40,7 @@ This workflow is triggered whenever a new tag is pushed to the repository (tags
40
40
41
41
2.**`create-release`:**
42
42
- Runs after successful deployment
43
-
- Creates a GitHub Release with the tag name
43
+
- Creates a GitHub Release with the tag name using `GITHUB_TOKEN` and `permissions: contents: write`
44
44
45
45
To trigger this workflow:
46
46
@@ -63,7 +63,7 @@ graph TD
63
63
64
64
## Technologies Used
65
65
66
-
-**Node.js**
66
+
-**Node.js 20.x (LTS)**
67
67
-**Express**
68
68
-**Jest** for testing
69
69
-**GitHub Actions** for CI/CD
@@ -103,4 +103,39 @@ The CI/CD pipeline requires the following secrets to be set in the GitHub reposi
103
103
- `DEV_EC2_HOST`: The hostname or IP address of the development EC2 instance.
104
104
- `DEV_EC2_USER`: The username for the development EC2 instance.
105
105
- `DEV_EC2_KEY`: The private SSH key for the development EC2 instance.
106
-
- `REPO_ACCESS_TOKEN`: A Personal Access Token (PAT) with `repo` scope. This is required forthe `bump-version` job to create tags that trigger other workflows. To create a PAT, go to your GitHub settings -> Developer settings -> Personal access tokens -> Tokens (classic) -> Generate new token. Give it a descriptive name and select the `repo` scope. Copy the token and add it as a secretin your repository settings.
106
+
- `REPO_ACCESS_TOKEN`: A Personal Access Token (classic) with `repo` scope. This is required for the `bump-version` job to create tags that trigger `release.yml`.
107
+
108
+
Optional:
109
+
- `HEALTHCHECK_ISSUE_TOKEN`: A Personal Access Token (classic) with `repo` scope if you prefer creating issues from the scheduled health-check with a PAT instead of the built-in token.
110
+
111
+
Repository Settings → Actions → General:
112
+
- Set Workflow permissions to “Read and write permissions” to allow the built-in token to create releases and issues.
113
+
114
+
## Health Check and Monitoring
115
+
116
+
- Health endpoint: `/api/health`.
117
+
- Workflow: `.github/workflows/health-check.yml` runs every 5 minutes and can be run manually via “Run workflow”.
118
+
- On failure, it creates an issue in the repository (requires write permissions as noted above).
119
+
120
+
## Deployment and Access
121
+
122
+
- Zero-downtime releases with PM2: the deploy script runs the app via the stable symlink `current/src/server.js` and swaps releases atomically.
123
+
- The app listens on `0.0.0.0:3000`. You can access it at:
124
+
- `http://YOUR_EC2_PUBLIC_IP:3000/`
125
+
- `http://YOUR_EC2_PUBLIC_IP:3000/api/health`
126
+
- If you prefer port 80/443, add an Nginx reverse proxy in front of the app. Example server block (HTTP only):
0 commit comments