39 lines
1.2 KiB
YAML
39 lines
1.2 KiB
YAML
name: Deploy to Cloudflare
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install Dependencies
|
|
run: npm install --legacy-peer-deps
|
|
|
|
- name: Build Next.js App
|
|
run: npm run build
|
|
|
|
- name: Deploy Worker and Pages
|
|
run: |
|
|
# Step 1: Build worker
|
|
cd worker
|
|
npx wrangler deploy src/index.ts --outdir dist
|
|
|
|
# Step 2: Build page
|
|
npx @cloudflare/next-on-pages
|
|
|
|
# Step 3: Upload worker
|
|
curl --fail-with-body -X PUT https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/workers/scripts/uptimeflare_worker/content --header 'Authorization: Bearer '$CLOUDFLARE_API_TOKEN -F 'index.js=@worker/dist/index.js;type=application/javascript+module' -F 'metadata={"main_module": "index.js"}'
|
|
|
|
# Step 4: Upload pages
|
|
npx wrangler pages deploy .vercel/output/static --project-name uptimeflare
|
|
env:
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|