Skip to content

Commit 1661e1f

Browse files
committed
Refresh EC2 pipeline runtime and rollback
1 parent 352d1d6 commit 1661e1f

9 files changed

Lines changed: 195 additions & 171 deletions

File tree

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
2-
extends: "airbnb-base",
2+
extends: 'airbnb-base',
33
env: {
44
node: true,
55
es2022: true,
66
jest: true,
77
},
88
rules: {
9-
"no-console": "off",
9+
'no-console': 'off',
1010
},
1111
};

.github/workflows/ci.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ on:
77
- development
88
- "feature/*"
99

10+
env:
11+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
12+
1013
jobs:
1114
build-and-test:
12-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
16+
strategy:
17+
matrix:
18+
node-version: ["22.x", "24.x"]
1319

1420
steps:
1521
- name: Checkout code
16-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
1723

18-
- name: Set up Node.js
19-
uses: actions/setup-node@v4
24+
- name: Set up Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v6
2026
with:
21-
node-version: "20"
27+
node-version: ${{ matrix.node-version }}
2228
cache: npm
2329
cache-dependency-path: package-lock.json
2430

@@ -28,15 +34,18 @@ jobs:
2834
- name: Run tests
2935
run: npm test
3036

37+
- name: Run linting
38+
run: npm run lint
39+
3140
bump-version:
3241
needs: build-and-test
3342
if: github.ref == 'refs/heads/main'
34-
runs-on: ubuntu-latest
43+
runs-on: ubuntu-24.04
3544
permissions:
3645
contents: write
3746
steps:
3847
- name: Checkout code
39-
uses: actions/checkout@v4
48+
uses: actions/checkout@v6
4049
with:
4150
fetch-depth: "0"
4251

.github/workflows/health-check.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ concurrency:
99
group: health-check
1010
cancel-in-progress: true
1111

12+
env:
13+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
14+
1215
jobs:
1316
health-check:
14-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-24.04
1518
permissions:
1619
issues: write
1720
contents: read
@@ -57,7 +60,7 @@ jobs:
5760
- name: Find existing health-check issue
5861
id: existing_issue
5962
if: failure() && steps.check.outputs.failed == 'true'
60-
uses: actions/github-script@v7
63+
uses: actions/github-script@v8
6164
with:
6265
script: |
6366
const { owner, repo } = context.repo;
@@ -69,7 +72,7 @@ jobs:
6972
7073
- name: Create health-check issue
7174
if: failure() && steps.check.outputs.failed == 'true' && steps.existing_issue.outputs.number == ''
72-
uses: actions/github-script@v7
75+
uses: actions/github-script@v8
7376
with:
7477
script: |
7578
const body = [
@@ -88,7 +91,7 @@ jobs:
8891
8992
- name: Update existing health-check issue
9093
if: failure() && steps.check.outputs.failed == 'true' && steps.existing_issue.outputs.number != ''
91-
uses: actions/github-script@v7
94+
uses: actions/github-script@v8
9295
with:
9396
script: |
9497
const body = [

.github/workflows/release.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ on:
55
tags:
66
- "v*"
77

8+
env:
9+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10+
811
jobs:
912
deploy:
10-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-24.04
1114
steps:
1215
- name: Checkout code
13-
uses: actions/checkout@v3
16+
uses: actions/checkout@v6
1417

1518
- name: Set up deployment environment
1619
run: |
@@ -39,22 +42,23 @@ jobs:
3942
# copy tarball to EC2
4043
scp -o StrictHostKeyChecking=no -i private_key.pem deployment.tar.gz $EC2_USER@$EC2_HOST:/tmp/
4144
42-
# extract and run deploy.sh on EC2
45+
# Extract and run deploy.sh from /tmp so /var/www/app only contains release-managed files.
4346
ssh -o StrictHostKeyChecking=no -i private_key.pem $EC2_USER@$EC2_HOST "
44-
mkdir -p /var/www/app &&
45-
tar -xzf /tmp/deployment.tar.gz -C /var/www/app &&
46-
chmod +x /var/www/app/scripts/deploy.sh &&
47-
/var/www/app/scripts/deploy.sh
47+
rm -rf /tmp/ec2-pipeline-deploy &&
48+
mkdir -p /tmp/ec2-pipeline-deploy /var/www/app &&
49+
tar -xzf /tmp/deployment.tar.gz -C /tmp/ec2-pipeline-deploy &&
50+
chmod +x /tmp/ec2-pipeline-deploy/scripts/deploy.sh &&
51+
/tmp/ec2-pipeline-deploy/scripts/deploy.sh
4852
"
4953
5054
create-release:
5155
needs: deploy
52-
runs-on: ubuntu-latest
56+
runs-on: ubuntu-24.04
5357
permissions:
5458
contents: write
5559
steps:
5660
- name: Checkout code
57-
uses: actions/checkout@v4
61+
uses: actions/checkout@v6
5862

5963
- name: Create GitHub Release
6064
uses: softprops/action-gh-release@v2

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Push to main / feature branch
1414
1515
└── ci.yml
16-
├── build-and-test: npm ci → Jest tests → pass/fail gate
16+
├── build-and-test: Node 22/24 matrix → npm ci → Jest tests → ESLint gate
1717
└── bump-version (main only): patch version bump → git tag v1.x.x
1818
1919
└── release.yml (triggered by tag v*)
@@ -26,7 +26,7 @@ Push to main / feature branch
2626
| Decision | Implementation | Why |
2727
|---|---|---|
2828
| **Low-interruption deploy** | `pm2 reload` + atomic symlink swap (`current -> release-timestamp`) | Keeps deploy behavior predictable and rollback-friendly |
29-
| **Auto-rollback** | `deploy.sh` keeps previous release; restores on failure | No manual intervention if deploy breaks the app |
29+
| **Auto-rollback** | `deploy.sh` keeps the previous `current` target until the new release passes health checks | Restores the last known-good symlink if deploy breaks the app |
3030
| **Automatic versioning** | `bump-version` job creates `v1.x.x` tags on every merge to main | Release history is automatic; no manual tagging |
3131
| **Health check monitoring** | Scheduled workflow runs hourly and reuses one open health-check issue while an outage is active | Avoids duplicate alert noise and keeps incident state readable |
3232
| **Separate CI / CD workflows** | `ci.yml` + `release.yml` split by tag trigger | CD only runs on verified, tagged builds — not every push |
@@ -38,7 +38,7 @@ Push to main / feature branch
3838
### `ci.yml` — Continuous Integration
3939
Triggers: push to `main`, `development`, `feature/*` branches + all PRs
4040

41-
1. **`build-and-test`**: `npm ci` → Jest test suite → pass required before merge
41+
1. **`build-and-test`**: Node 22/24 matrix → `npm ci` → Jest test suite → ESLint gate
4242
2. **`bump-version`** (main only): increments patch version, pushes `v1.x.x` tag — triggers `release.yml`
4343

4444
### `release.yml` — Continuous Deployment
@@ -69,7 +69,9 @@ Also set: **Actions → General → Workflow permissions → Read and write** (a
6969

7070
## Application Stack
7171

72-
`Node.js 20 LTS` · `Express` · `Jest` · `PM2` · `GitHub Actions` · `AWS EC2`
72+
`Node.js 22/24` · `Express` · `Jest` · `PM2` · `GitHub Actions` · `AWS EC2`
73+
74+
The EC2 host should run Node.js 22 or 24 so the deployed runtime matches CI.
7375

7476
---
7577

0 commit comments

Comments
 (0)