diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1857eeb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +--- +name: Site Build +on: + push: + branches: [ deployment ] + +jobs: + site-build: + runs-on: ubuntu-latest + container: node:22-alpine + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Install Yarn Dependencies + run: cd apps/front && yarn install + - name: Build Site + run: cd apps/front && npm run build:worker diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..41b1e49 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,24 @@ +--- +name: Site Deploy +on: + push: + tags: + - '*' + +jobs: + site-deploy: + runs-on: ubuntu-latest + container: + image: node:22-alpine + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + NEXT_PUBLIC_STRAPI_API_TOKEN: ${{ secrets.NEXT_PUBLIC_STRAPI_API_TOKEN }} + NEXT_PUBLIC_STRAPI_BASE_URL: ${{ secrets.NEXT_PUBLIC_STRAPI_BASE_URL }} + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Install Yarn Dependencies + run: cd apps/front && yarn install + - name: Deploy Site + run: cd apps/front && npm run deploy:worker diff --git a/apps/front/open-next.config.ts b/apps/front/open-next.config.ts new file mode 100644 index 0000000..a62dbe7 --- /dev/null +++ b/apps/front/open-next.config.ts @@ -0,0 +1,7 @@ +// default open-next.config.ts file created by @opennextjs/cloudflare +import { defineCloudflareConfig } from "@opennextjs/cloudflare/config"; +import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache"; + +export default defineCloudflareConfig({ + incrementalCache: kvIncrementalCache, +}); diff --git a/apps/front/package.json b/apps/front/package.json index e4c0f5b..0974b43 100644 --- a/apps/front/package.json +++ b/apps/front/package.json @@ -3,6 +3,10 @@ "version": "0.9.0", "private": true, "scripts": { + "build:worker": "opennextjs-cloudflare", + "dev:worker": "wrangler dev --port 8771", + "preview:worker": "npm run build:worker && npm run dev:worker", + "deploy:worker": "npm run build:worker && wrangler deploy", "dev": "next dev", "build": "next build", "start": "next start", @@ -30,11 +34,12 @@ "swiper": "^11.2.1" }, "engines": { - "node": ">=18.0.0 <=20.x.x", + "node": ">=18.0.0 <=22.x.x", "npm": ">=6.0.0" }, "devDependencies": { "@eslint/eslintrc": "^3", + "@opennextjs/cloudflare": "^0.5.8", "@types/node": "^20", "@types/qs": "^6.9.18", "@types/react": "^18.2.45", @@ -45,6 +50,7 @@ "eslint-config-next": "15.1.3", "postcss": "^8", "tailwindcss": "^3.4.1", - "typescript": "^5" + "typescript": "^5", + "wrangler": "^3.114.0" } } diff --git a/apps/front/wrangler.jsonc b/apps/front/wrangler.jsonc new file mode 100644 index 0000000..533c6ae --- /dev/null +++ b/apps/front/wrangler.jsonc @@ -0,0 +1,12 @@ +{ + "main": ".open-next/worker.js", + "name": "ai-nekko-web", + "compatibility_date": "2024-09-23", + "compatibility_flags": [ + "nodejs_compat" + ], + "assets": { + "directory": ".open-next/assets", + "binding": "ASSETS" + } +} diff --git a/package-lock.json b/package-lock.json index bf32578..da147ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,7 @@ "typescript": "^5" }, "engines": { - "node": ">=18.0.0 <=20.x.x", + "node": ">=18.0.0 <=22.x.x", "npm": ">=6.0.0" } }, @@ -6438,7 +6438,7 @@ "pack-up": "bin/pack-up.js" }, "engines": { - "node": ">=18.0.0 <=20.x.x", + "node": ">=18.0.0 <=22.x.x", "npm": ">=6.0.0" } }, diff --git a/package.json b/package.json index 5398534..3a5c2ca 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "workspaces": { "packages": [ - "apps/*" + "apps/front/" ], "nohoist": [ "**/@strapi/strapi", @@ -12,6 +12,10 @@ ] }, "scripts": { + "build:worker": "opennextjs-cloudflare", + "dev:worker": "wrangler dev --port 8771", + "preview:worker": "npm run build:worker && npm run dev:worker", + "deploy:worker": "npm run build:worker && wrangler deploy", "build": "turbo run build --filter=apps/front", "dev": "turbo run dev --filter=apps/front", "lint": "turbo run lint", @@ -20,6 +24,8 @@ "commit": "git-cz" }, "devDependencies": { + "@opennextjs/cloudflare": "^0.5.8", + "wrangler": "^3.114.0", "turbo": "1.10.6" }, "engines": {