From d65f1bf1470fe82c90f07e91a01ab913754574d8 Mon Sep 17 00:00:00 2001 From: Claire Sylvester Date: Mon, 16 Jun 2025 09:38:25 -0700 Subject: [PATCH 1/4] github actions --- .github/workflows/ci.yml | 83 ++++++++++++++++++++++++++++++++++++++++ README.md | 46 +++++++++++----------- package.json | 3 +- 3 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0ec4a74 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: 🚨 CI Checks + +on: + push: + branches: + - main + - staging + pull_request: + branches: + - '**' + +jobs: + check-main-override: + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: 🛑 Prevent direct push to main without override + run: | + echo "Checking for override..." + if [[ "${{ github.event.head_commit.message }}" != *"[override-main]"* ]]; then + echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message." + exit 1 + fi + echo "✅ Override flag found. Proceeding." + + 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 + + - name: đŸ“Ļ Install dependencies + run: yarn install --frozen-lockfile + + - name: Run Linter + 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 + + - name: đŸ“Ļ Install dependencies + run: yarn install --frozen-lockfile + + - name: Run TypeScript + 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 + + - name: đŸ“Ļ Install dependencies + 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 }}- + + - name: Build App + 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", From fdd1992c5a7ad0992dc34c418e12c4d08d2c5a0b Mon Sep 17 00:00:00 2001 From: Claire Sylvester Date: Mon, 16 Jun 2025 09:41:35 -0700 Subject: [PATCH 2/4] fix action --- .github/workflows/ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ec4a74..b4a9233 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,19 +13,24 @@ jobs: check-main-override: if: github.ref == 'refs/heads/main' && github.event_name == 'push' runs-on: ubuntu-latest + outputs: + bypassed: ${{ steps.override.outputs.bypassed }} steps: - name: 🛑 Prevent direct push to main without override + id: override run: | - echo "Checking for override..." - if [[ "${{ github.event.head_commit.message }}" != *"[override-main]"* ]]; then + if [[ "${{ github.event.head_commit.message }}" == *"[override-main]"* ]]; then + echo "✅ Override flag found. Proceeding." + echo "bypassed=true" >> $GITHUB_OUTPUT + else echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message." exit 1 fi - echo "✅ Override flag found. Proceeding." lint: name: 🔍 Lint runs-on: ubuntu-latest + if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' needs: [check-main-override] steps: - uses: actions/checkout@v4 @@ -43,6 +48,7 @@ jobs: typecheck: name: ✅ Type Check runs-on: ubuntu-latest + if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' needs: [check-main-override] steps: - uses: actions/checkout@v4 @@ -60,6 +66,7 @@ jobs: build: name: 🔨 Build runs-on: ubuntu-latest + if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' needs: [check-main-override] steps: - uses: actions/checkout@v4 From f9a0f20f867b0457b1eb8e16e4c4f5e741dd93ff Mon Sep 17 00:00:00 2001 From: Claire Sylvester Date: Mon, 16 Jun 2025 09:43:13 -0700 Subject: [PATCH 3/4] try again --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4a9233..ba51931 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,21 +11,21 @@ on: jobs: check-main-override: - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - runs-on: ubuntu-latest - outputs: - bypassed: ${{ steps.override.outputs.bypassed }} - steps: - - name: 🛑 Prevent direct push to main without override - id: override - run: | - if [[ "${{ github.event.head_commit.message }}" == *"[override-main]"* ]]; then - echo "✅ Override flag found. Proceeding." - echo "bypassed=true" >> $GITHUB_OUTPUT - else + runs-on: ubuntu-latest + steps: + - name: 🛑 Block direct pushes to main (unless override flag) + run: | + echo "🔍 Checking push context: ${{ github.event_name }} → ${{ github.ref }}" + if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then + if [[ "${{ github.event.head_commit.message }}" != *"[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. Allowing push to main." fi + else + echo "â„šī¸ Not a direct push to main. Skipping protection." + fi lint: name: 🔍 Lint From b0c387789b35d16288d198729f49afcabcb04bc9 Mon Sep 17 00:00:00 2001 From: Claire Sylvester Date: Mon, 16 Jun 2025 09:44:52 -0700 Subject: [PATCH 4/4] try again --- .github/workflows/ci.yml | 62 ++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba51931..d1d56af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,73 +11,61 @@ on: jobs: check-main-override: - runs-on: ubuntu-latest - steps: - - name: 🛑 Block direct pushes to main (unless override flag) - run: | - echo "🔍 Checking push context: ${{ github.event_name }} → ${{ github.ref }}" - if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then - if [[ "${{ github.event.head_commit.message }}" != *"[override-main]"* ]]; then - echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message." - exit 1 + 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 "✅ Override flag found. Allowing push to main." + echo "â„šī¸ Not a direct push to main. Proceeding." fi - else - echo "â„šī¸ Not a direct push to main. Skipping protection." - fi lint: name: 🔍 Lint runs-on: ubuntu-latest - if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' - needs: [check-main-override] + needs: check-main-override steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: yarn - - - name: đŸ“Ļ Install dependencies - run: yarn install --frozen-lockfile - - - name: Run Linter - run: yarn lint + - run: yarn install --frozen-lockfile + - run: yarn lint typecheck: name: ✅ Type Check runs-on: ubuntu-latest - if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' - needs: [check-main-override] + needs: check-main-override steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: yarn - - - name: đŸ“Ļ Install dependencies - run: yarn install --frozen-lockfile - - - name: Run TypeScript - run: yarn typecheck + - run: yarn install --frozen-lockfile + - run: yarn typecheck build: name: 🔨 Build runs-on: ubuntu-latest - if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' - needs: [check-main-override] + needs: check-main-override steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: yarn - - - name: đŸ“Ļ Install dependencies - run: yarn install --frozen-lockfile - + - run: yarn install --frozen-lockfile - name: ⚡ Cache .next build uses: actions/cache@v4 with: @@ -85,6 +73,4 @@ jobs: key: next-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} restore-keys: | next-${{ runner.os }}- - - - name: Build App - run: yarn build + - run: yarn build