Skip to content

Commit d65f1bf

Browse files
committed
github actions
1 parent cf688a9 commit d65f1bf

File tree

3 files changed

+109
-23
lines changed

3 files changed

+109
-23
lines changed

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: 🚨 CI Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- staging
8+
pull_request:
9+
branches:
10+
- '**'
11+
12+
jobs:
13+
check-main-override:
14+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: 🛑 Prevent direct push to main without override
18+
run: |
19+
echo "Checking for override..."
20+
if [[ "${{ github.event.head_commit.message }}" != *"[override-main]"* ]]; then
21+
echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message."
22+
exit 1
23+
fi
24+
echo "✅ Override flag found. Proceeding."
25+
26+
lint:
27+
name: 🔍 Lint
28+
runs-on: ubuntu-latest
29+
needs: [check-main-override]
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 22
35+
cache: yarn
36+
37+
- name: 📦 Install dependencies
38+
run: yarn install --frozen-lockfile
39+
40+
- name: Run Linter
41+
run: yarn lint
42+
43+
typecheck:
44+
name: ✅ Type Check
45+
runs-on: ubuntu-latest
46+
needs: [check-main-override]
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: 22
52+
cache: yarn
53+
54+
- name: 📦 Install dependencies
55+
run: yarn install --frozen-lockfile
56+
57+
- name: Run TypeScript
58+
run: yarn typecheck
59+
60+
build:
61+
name: 🔨 Build
62+
runs-on: ubuntu-latest
63+
needs: [check-main-override]
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-node@v4
67+
with:
68+
node-version: 22
69+
cache: yarn
70+
71+
- name: 📦 Install dependencies
72+
run: yarn install --frozen-lockfile
73+
74+
- name: ⚡ Cache .next build
75+
uses: actions/cache@v4
76+
with:
77+
path: .next
78+
key: next-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
79+
restore-keys: |
80+
next-${{ runner.os }}-
81+
82+
- name: Build App
83+
run: yarn build

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
[![Yarn](https://img.shields.io/badge/Yarn->=1.22.0-F7740D?style=flat&logo=yarn)](https://yarnpkg.com/)
5252
[![VS Code](https://img.shields.io/badge/Editor-VS%20Code-666666?style=flat&logo=visual-studio-code)](https://code.visualstudio.com/)
5353

54+
> ⚠️ Direct pushes to `main` are blocked by CI unless the commit message includes `[override-main]`.
55+
> Use Pull Requests into `main`, or merge from `staging`.
56+
5457
## Getting Started
5558

5659
1. Clone the repository:
@@ -411,26 +414,25 @@ useEffect(() => {
411414
Add the grid system to your server render layout found in `layout.tsx` within the app directory:
412415

413416
```tsx
414-
// check env vars
415-
const devMode = process.env.NODE_ENV === 'development';
416-
const isGridOverlayOverride = process.env.GRID_OVERLAY_OVERRIDE === 'true';
417-
418-
// show grid overlay if dev mode is true or if the grid overlay override is true
419-
const showGridOverlay = devMode || isGridOverlayOverride;
420-
421-
return (
422-
<html lang="en" className={montserrat.variable}>
423-
<body>
424-
{/* DEV GRID TOGGLE */}
425-
{showGridOverlay && <GridOverlayToggle />}
426-
427-
{/* MAIN CONTENT */}
428-
{/* GRID OVERLAY relies on the layout class */}
429-
<main data-grid-overlay className={'layout'}>
430-
{children}
431-
</main>
432-
</body>
433-
</html>
434-
);
435-
417+
// check env vars
418+
const devMode = process.env.NODE_ENV === 'development';
419+
const isGridOverlayOverride = process.env.GRID_OVERLAY_OVERRIDE === 'true';
420+
421+
// show grid overlay if dev mode is true or if the grid overlay override is true
422+
const showGridOverlay = devMode || isGridOverlayOverride;
423+
424+
return (
425+
<html lang="en" className={montserrat.variable}>
426+
<body>
427+
{/* DEV GRID TOGGLE */}
428+
{showGridOverlay && <GridOverlayToggle />}
429+
430+
{/* MAIN CONTENT */}
431+
{/* GRID OVERLAY relies on the layout class */}
432+
<main data-grid-overlay className={'layout'}>
433+
{children}
434+
</main>
435+
</body>
436+
</html>
437+
);
436438
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"lint": "next lint",
1414
"lint:fix": "next lint --fix",
1515
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
16-
"check-format": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\""
16+
"check-format": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
17+
"typecheck": "tsc --noEmit"
1718
},
1819
"dependencies": {
1920
"change-case": "^5.4.4",

0 commit comments

Comments
 (0)