https://github.com/mstrlaw/trunk-dev
Trunk Based Development using GitHub workflows for CI/CD
https://github.com/mstrlaw/trunk-dev
cicd poc trunk-based-development
Last synced: 28 days ago
JSON representation
Trunk Based Development using GitHub workflows for CI/CD
- Host: GitHub
- URL: https://github.com/mstrlaw/trunk-dev
- Owner: mstrlaw
- Created: 2025-01-17T15:18:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-17T21:45:30.000Z (about 1 year ago)
- Last Synced: 2025-10-28T13:14:03.827Z (5 months ago)
- Topics: cicd, poc, trunk-based-development
- Language: JavaScript
- Homepage: https://trunk-dev.vercel.app
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Trunk Based Development PoC
### Complete repo demonstrating how to setup GitHub Actions for doing [Trunk Based Development](https://trunkbaseddevelopment.com/)
#### Environments
[](https://trunk-dev.vercel.app/)
[](https://trunk-dev-staging.vercel.app/)
**Bonus**:
- Using [Playwright](https://playwright.dev/) for running E2E tests when integrating code
- Deploying to [Vercel](https://vercel.com/)
### Workflow Concepts
1. A Workflow is what GitHub calls Action(s)
2. Actions can have one or more Jobs, with one or more Steps
3. Workflows are created under `.github/workflows` (GitHub treats any yml file under `workflows` as an Action to be executed)
4. File name follows a pattern to loosely indicate the trigger method `on_.yml`
### How it works
1. Dev _commits code_ to any branch (no open PR yet) -> Execute Linting job and deploys a preview URL to Vercel
2. PR is _opened_ into `main` branch -> Execute Test jobs
3. PR is _merged_ into `main` branch -> Project deployed to Staging env
4. Tag is _created_ from `main` branch -> Project deployed to Production env
```mermaid
sequenceDiagram
actor D as Dev
participant B as Branch
participant M as Main
participant V as Vercel
box GitHub
participant B
participant M
end
loop Push Code
D->>B: Commit XYZ
Note over B: 1.Lint
2.Built
3.Trigger Vercel Deploy
B->>V: Deploy
Note over V: github-actions-vercel-8ga3p0aks-surfe.vercel.app
end
alt Open PR
B->>M: New PR
Note over M: 1.Build
2.1.Run Tests (Unit)
2.2.Run Tests (E2E)
end
alt Merge PR
B->>M: Merge PR
Note over M: 1.Build
2.Trigger Vercel Deploy
M->>V: Deploy
Note over V: trunkbased-cicd-workflow-staging.vercel.app
end
loop Create Tag
Note over M: 1.Build
2.Trigger Vercel Deploy
M->>V: Deploy
Note over V: trunkbased-cicd-workflow.vercel.app
end
```
### PoC Details
- Project is a simple static site with 2 pages
- Server is ran using [PM2](https://www.npmjs.com/package/pm2), which allows to run it in the background without blocking execution of job steps
- Interfacing with Vercel in the CI is done using their [CLI](https://vercel.com/docs/cli)
- Vercel project and org keys must be setup for using the CLI