Skip to content

Commit 03b027b

Browse files
committed
Use controlled EC2 release trigger
1 parent 1661e1f commit 03b027b

3 files changed

Lines changed: 9 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,3 @@ jobs:
3636

3737
- name: Run linting
3838
run: npm run lint
39-
40-
bump-version:
41-
needs: build-and-test
42-
if: github.ref == 'refs/heads/main'
43-
runs-on: ubuntu-24.04
44-
permissions:
45-
contents: write
46-
steps:
47-
- name: Checkout code
48-
uses: actions/checkout@v6
49-
with:
50-
fetch-depth: "0"
51-
52-
- name: Bump version and push tag
53-
uses: anothrNick/github-tag-action@v1
54-
env:
55-
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
56-
DEFAULT_BUMP: patch
57-
TAG_PREFIX: v
58-
WITH_V: true # Ensures consistent v prefix
59-
SKIP_TAG_PUSH: false
60-
CREATE_ANNOTATED_TAG: true

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- "v*"
7+
workflow_dispatch:
78

89
env:
910
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
@@ -53,6 +54,7 @@ jobs:
5354
5455
create-release:
5556
needs: deploy
57+
if: startsWith(github.ref, 'refs/tags/')
5658
runs-on: ubuntu-24.04
5759
permissions:
5860
contents: write

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# github-actions-ec2-pipeline
22

3-
> GitHub Actions pipeline that builds, tests, versions, and deploys a Node.js app
3+
> GitHub Actions pipeline that builds, tests, and deploys a Node.js app
44
> to AWS EC2 with PM2 reload, rollback support, and scheduled health checks.
55
66
[![CI Pipeline](https://github.com/darestack/github-actions-ec2-pipeline/actions/workflows/ci.yml/badge.svg)](https://github.com/darestack/github-actions-ec2-pipeline/actions/workflows/ci.yml)
@@ -13,12 +13,11 @@
1313
Push to main / feature branch
1414
1515
└── ci.yml
16-
├── build-and-test: Node 22/24 matrix → npm ci → Jest tests → ESLint gate
17-
└── bump-version (main only): patch version bump → git tag v1.x.x
16+
└── build-and-test: Node 22/24 matrix → npm ci → Jest tests → ESLint gate
1817
19-
└── release.yml (triggered by tag v*)
18+
└── release.yml (manual dispatch or pushed v* tag)
2019
├── deploy: tar.gz → SCP to EC2 → deploy.sh (PM2 reload, atomic symlink swap)
21-
└── create-release: GitHub Release with changelog
20+
└── create-release: GitHub Release for tagged deploys
2221
```
2322

2423
### Key Design Decisions
@@ -27,9 +26,9 @@ Push to main / feature branch
2726
|---|---|---|
2827
| **Low-interruption deploy** | `pm2 reload` + atomic symlink swap (`current -> release-timestamp`) | Keeps deploy behavior predictable and rollback-friendly |
2928
| **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 |
30-
| **Automatic versioning** | `bump-version` job creates `v1.x.x` tags on every merge to main | Release history is automatic; no manual tagging |
29+
| **Controlled release trigger** | `release.yml` runs from a manual dispatch or pushed `v*` tag | Avoids accidental EC2 deploys from routine CI commits |
3130
| **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 |
32-
| **Separate CI / CD workflows** | `ci.yml` + `release.yml` split by tag trigger | CD only runs on verified, tagged builds — not every push |
31+
| **Separate CI / CD workflows** | `ci.yml` validates code; `release.yml` deploys from manual or tag triggers | Keeps routine validation separate from EC2 deployment |
3332

3433
---
3534

@@ -39,10 +38,9 @@ Push to main / feature branch
3938
Triggers: push to `main`, `development`, `feature/*` branches + all PRs
4039

4140
1. **`build-and-test`**: Node 22/24 matrix → `npm ci` → Jest test suite → ESLint gate
42-
2. **`bump-version`** (main only): increments patch version, pushes `v1.x.x` tag — triggers `release.yml`
4341

4442
### `release.yml` — Continuous Deployment
45-
Triggers: new tag matching `v*`
43+
Triggers: manual dispatch or new tag matching `v*`
4644

4745
1. **`deploy`**: packages build → SCP to EC2 → runs `/var/www/app/scripts/deploy.sh`
4846
- Installs dependencies in release dir → atomic symlink `current``pm2 reload`
@@ -61,7 +59,6 @@ Runs hourly. Hits `/api/health` for configured environments. If a check fails, t
6159
| `PROD_EC2_HOST` | Production EC2 hostname or IP |
6260
| `PROD_EC2_USER` | SSH username |
6361
| `PROD_EC2_KEY` | Private SSH key (PEM format) |
64-
| `REPO_ACCESS_TOKEN` | PAT with `repo` scope — needed for `bump-version` to push tags |
6562

6663
Also set: **Actions → General → Workflow permissions → Read and write** (allows built-in token to create releases and issues).
6764

0 commit comments

Comments
 (0)