Skip to content

Commit a13cd67

Browse files
authored
Merge pull request #3 from CFsylvester/github-actions
GitHub actions
2 parents f364c6c + b0c3877 commit a13cd67

File tree

3 files changed

+102
-23
lines changed

3 files changed

+102
-23
lines changed

.github/workflows/ci.yml

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