53 lines
1.2 KiB
YAML
53 lines
1.2 KiB
YAML
name: Deploy to Cloudflare Workers
|
|
|
|
on:
|
|
workflow_dispatch: # 允许手动触发
|
|
|
|
# 部署所需权限
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
name: Deploy Worker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate wrangler.toml with admin credentials
|
|
run: |
|
|
cat > wrangler.toml << EOF
|
|
name = "ai-gateway"
|
|
main = "src/index.ts"
|
|
compatibility_date = "2025-07-01"
|
|
compatibility_flags = ["nodejs_compat"]
|
|
keep_vars = true
|
|
|
|
[[kv_namespaces]]
|
|
binding = "KV"
|
|
|
|
[vars]
|
|
ADMIN_USERNAME = ${{ vars.ADMIN_USERNAME }}
|
|
ADMIN_PASSWORD = ${{ vars.ADMIN_PASSWORD }}
|
|
EOF
|
|
|
|
- name: Build (dry-run)
|
|
run: npm run build
|
|
|
|
- name: Deploy to Cloudflare Workers
|
|
uses: cloudflare/wrangler-action@v3
|
|
with:
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
|