Skip to content

Commit cc8b2eb

Browse files
authored
Merge pull request #4 from CFsylvester/staging
Staging
2 parents cf688a9 + 1ede31b commit cc8b2eb

File tree

3 files changed

+98
-23
lines changed

3 files changed

+98
-23
lines changed

.github/workflows/ci.yml

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