Skip to content

Commit

Permalink
Merge pull request #158 from xicri/chore-cloudflare-pages
Browse files Browse the repository at this point in the history
Migrate server to Cloudflare Pages
  • Loading branch information
xicri authored Aug 2, 2024
2 parents 8b957a3 + bdcd0be commit 55d90e7
Show file tree
Hide file tree
Showing 16 changed files with 1,015 additions and 145 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,3 @@ jobs:
- run: npm run build
- run: npm test
- run: npm run lint

staging:
if: ${{ github.ref != 'refs/heads/main' && github.repository_owner == 'xicri' }}
timeout-minutes: 10
env:
SERVER_ENV: staging
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master

- run: npm run stage

production:
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'xicri' }}
needs: test
timeout-minutes: 10
env:
SERVER_ENV: production
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: npm
- uses: superfly/flyctl-actions/setup-flyctl@master

- run: npm run release
21 changes: 21 additions & 0 deletions .github/workflows/purge-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Purge cache of Cloudflare CDN"

on:
check_run:
types:
- completed

jobs:
trigger:
if: ${{ github.event.check_run.name == 'Cloudflare Pages' && github.event.check_run.conclusion == 'success' && github.event.check_run.head_sha == github.sha && github.ref == 'refs/heads/main' && github.repository_owner == 'xicri' }}
timeout-minutes: 3
runs-on: ubuntu-latest
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

steps:
- name: Purge cache of Cloudflare CDN
run: |
npm install esno undici
npm run purge-cache
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ yarn-error.log*
# Nuxt
.nuxt
/.output/
# When nitro.preset: "cloudflare-pages" is set in nuxt.config.ts,
# build output is placed in dist/
/dist/

# npm is the package manager for this project.
yarn.lock
Expand All @@ -65,6 +68,11 @@ yarn.lock
/public/robots.txt
/public/sitemap.xml

# Cloudflare / Wrangler
.wrangler
.dev.vars
worker-configuration.d.ts

# Misc
.node_repl_history
.eslintcache
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

36 changes: 0 additions & 36 deletions fly.toml

This file was deleted.

4 changes: 3 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import words from "./dataset/words.json";
const isLocal = !process.env.SERVER_ENV || process.env.SERVER_ENV === "local";

export default defineNuxtConfig({
compatibilityDate: "2024-07-31",
ssr: true,
components: true,

nitro: {
preset: "node-server",
preset: "cloudflare-pages",
},
typescript: {
strict: true,
Expand All @@ -21,6 +22,7 @@ export default defineNuxtConfig({
},

modules: [
"nitro-cloudflare-dev",
"@nuxtjs/i18n",
"@nuxtjs/sitemap",
"@pinia/nuxt",
Expand Down
Loading

0 comments on commit 55d90e7

Please sign in to comment.