Skip to content

Commit

Permalink
chore: add cloudflare deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ourongxing committed Apr 17, 2023
1 parent 6ddef5d commit 8eda4f3
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
46 changes: 46 additions & 0 deletions .github/workflow/cloudflate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: cloudflare

on:
push:
branches: [ main]
workflow_dispatch:

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest ]
node: [ 18 ]

steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Setup PNPM
uses: pnpm/[email protected]
with:
version: 7.13.2

- name: Cache node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/pnpm-lock.yaml')) }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm i

- name: Build
run: CF_WORKER=1 pnpm build

- name: Publish to Cloudflare
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"undici": "^5.21.2"
},
"devDependencies": {
"@cloudflare/kv-asset-handler": "^0.3.0",
"@iconify-json/carbon": "^1.1.16",
"@iconify-json/ri": "^1.1.7",
"@types/markdown-it": "^12.2.3",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const adapter = () => {
return vercel({ edge: true })
} else if (process.env.NETLIFY) {
return netlify({ edge: true })
} else if (process.env.CLOUDFLARE_WORKER) {
} else if (process.env.CF_WORKER) {
return cloudflare({})
} else {
return node()
Expand Down
5 changes: 3 additions & 2 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
main = "./dist/server.js"
compatibility_date = "2023-04-17"
name = "chatgpt"
[site]
bucket= "./dist/public"
[vars]
NODE_VERSION = "18"
CLOUDFLARE_WORKER = "true"
NODE_VERSION = "18"

0 comments on commit 8eda4f3

Please sign in to comment.