From a131c946bf48b93375f59ab02e09e9e28a390398 Mon Sep 17 00:00:00 2001 From: Sergei Bondar Date: Wed, 8 Oct 2025 15:11:24 +0400 Subject: [PATCH 1/3] add_gha --- .github/workflows/deploy-cf.yml | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/deploy-cf.yml diff --git a/.github/workflows/deploy-cf.yml b/.github/workflows/deploy-cf.yml new file mode 100644 index 0000000..4f64075 --- /dev/null +++ b/.github/workflows/deploy-cf.yml @@ -0,0 +1,43 @@ +name: Deploy CF + +on: + workflow_dispatch: + push: + branches: + - main + - develop + +jobs: + distribute-resources: + runs-on: ["gha-runner-scale-set-neonevm"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project (Next.js) + env: + NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} + NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} + SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} + NEXT_PUBLIC_APP_URL: ${{ github.ref == 'refs/heads/main' && 'https://cookie.neonevm.org' || 'https://develop.fortune-cookie.pages.dev' }} + run: npm run build + + - name: Generate Cloudflare Pages artifacts (Next on Pages) + run: npx --yes @cloudflare/next-on-pages@latest + + - name: Publish to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CF_PAGES_TOKEN }} + command: | + pages deploy ./.vercel/output/static --project-name="fortune-cookie" From 578971b598fc75cfc710d483c066b8787297670a Mon Sep 17 00:00:00 2001 From: Sergei Bondar Date: Wed, 8 Oct 2025 15:18:35 +0400 Subject: [PATCH 2/3] add_gha --- .github/workflows/deploy-cf.yml | 2 +- src/app/api/fortune/route.ts | 1 + src/app/api/variants/route.ts | 1 + src/app/f/[slug]/page.tsx | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-cf.yml b/.github/workflows/deploy-cf.yml index 4f64075..9abb521 100644 --- a/.github/workflows/deploy-cf.yml +++ b/.github/workflows/deploy-cf.yml @@ -8,7 +8,7 @@ on: - develop jobs: - distribute-resources: + build-and-deploy: runs-on: ["gha-runner-scale-set-neonevm"] steps: diff --git a/src/app/api/fortune/route.ts b/src/app/api/fortune/route.ts index 087e921..4cff67b 100644 --- a/src/app/api/fortune/route.ts +++ b/src/app/api/fortune/route.ts @@ -1,3 +1,4 @@ +export const runtime = 'edge' import { NextRequest, NextResponse } from 'next/server' import { nanoid } from 'nanoid' import { getRandomImage, createFortune, logEvent } from '@/lib/supabase' diff --git a/src/app/api/variants/route.ts b/src/app/api/variants/route.ts index 66682d3..6f249b8 100644 --- a/src/app/api/variants/route.ts +++ b/src/app/api/variants/route.ts @@ -1,3 +1,4 @@ +export const runtime = 'edge' import { NextResponse } from 'next/server' import { supabase } from '@/lib/supabase' diff --git a/src/app/f/[slug]/page.tsx b/src/app/f/[slug]/page.tsx index 8c9893a..10a1b8e 100644 --- a/src/app/f/[slug]/page.tsx +++ b/src/app/f/[slug]/page.tsx @@ -1,3 +1,4 @@ +export const runtime = 'edge' import { Metadata } from 'next' import { notFound } from 'next/navigation' import { getFortuneBySlug, logEvent } from '@/lib/supabase' From b28cc946b280103fdcb57bbf1bea34b2a60143d0 Mon Sep 17 00:00:00 2001 From: Sergei Bondar Date: Wed, 8 Oct 2025 15:37:59 +0400 Subject: [PATCH 3/3] add_gha --- .github/workflows/deploy-cf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-cf.yml b/.github/workflows/deploy-cf.yml index 9abb521..d4c9e28 100644 --- a/.github/workflows/deploy-cf.yml +++ b/.github/workflows/deploy-cf.yml @@ -29,7 +29,7 @@ jobs: NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} - NEXT_PUBLIC_APP_URL: ${{ github.ref == 'refs/heads/main' && 'https://cookie.neonevm.org' || 'https://develop.fortune-cookie.pages.dev' }} + NEXT_PUBLIC_APP_URL: ${{ github.ref == 'refs/heads/main' && 'https://cookie.neonevm.org' || 'https://develop.fortune-cookie-4bg.pages.dev' }} run: npm run build - name: Generate Cloudflare Pages artifacts (Next on Pages)