diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d1d56af --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +name: 🚨 CI Checks + +on: + push: + branches: + - main + - staging + pull_request: + branches: + - '**' + +jobs: + check-main-override: + runs-on: ubuntu-latest + steps: + - name: 🛑 Block direct pushes to main (unless override flag) + run: | + echo "🔍 Event: ${{ github.event_name }} | Ref: ${{ github.ref }}" + if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then + COMMIT_MSG="${{ github.event.head_commit.message }}" + echo "🔍 Commit message: $COMMIT_MSG" + if [[ "$COMMIT_MSG" != *"[override-main]"* ]]; then + echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message." + exit 1 + else + echo "✅ Override flag found. Proceeding." + fi + else + echo "â„šī¸ Not a direct push to main. Proceeding." + fi + + lint: + name: 🔍 Lint + runs-on: ubuntu-latest + needs: check-main-override + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: yarn + - run: yarn install --frozen-lockfile + - run: yarn lint + + typecheck: + name: ✅ Type Check + runs-on: ubuntu-latest + needs: check-main-override + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: yarn + - run: yarn install --frozen-lockfile + - run: yarn typecheck + + build: + name: 🔨 Build + runs-on: ubuntu-latest + needs: check-main-override + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: yarn + - run: yarn install --frozen-lockfile + - name: ⚡ Cache .next build + uses: actions/cache@v4 + with: + path: .next + key: next-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + next-${{ runner.os }}- + - run: yarn build diff --git a/README.md b/README.md index 8fc6daf..7697557 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ [![Yarn](https://img.shields.io/badge/Yarn->=1.22.0-F7740D?style=flat&logo=yarn)](https://yarnpkg.com/) [![VS Code](https://img.shields.io/badge/Editor-VS%20Code-666666?style=flat&logo=visual-studio-code)](https://code.visualstudio.com/) +> âš ī¸ Direct pushes to `main` are blocked by CI unless the commit message includes `[override-main]`. +> Use Pull Requests into `main`, or merge from `staging`. + ## Getting Started 1. Clone the repository: @@ -411,26 +414,25 @@ useEffect(() => { Add the grid system to your server render layout found in `layout.tsx` within the app directory: ```tsx - // check env vars - const devMode = process.env.NODE_ENV === 'development'; - const isGridOverlayOverride = process.env.GRID_OVERLAY_OVERRIDE === 'true'; - - // show grid overlay if dev mode is true or if the grid overlay override is true - const showGridOverlay = devMode || isGridOverlayOverride; - - return ( - - - {/* DEV GRID TOGGLE */} - {showGridOverlay && } - - {/* MAIN CONTENT */} - {/* GRID OVERLAY relies on the layout class */} -
- {children} -
- - - ); - +// check env vars +const devMode = process.env.NODE_ENV === 'development'; +const isGridOverlayOverride = process.env.GRID_OVERLAY_OVERRIDE === 'true'; + +// show grid overlay if dev mode is true or if the grid overlay override is true +const showGridOverlay = devMode || isGridOverlayOverride; + +return ( + + + {/* DEV GRID TOGGLE */} + {showGridOverlay && } + + {/* MAIN CONTENT */} + {/* GRID OVERLAY relies on the layout class */} +
+ {children} +
+ + +); ``` diff --git a/package.json b/package.json index 8db9831..1f07104 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "lint": "next lint", "lint:fix": "next lint --fix", "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"", - "check-format": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"" + "check-format": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"", + "typecheck": "tsc --noEmit" }, "dependencies": { "change-case": "^5.4.4",