Merge pull request #10 from kimitrii/kimitri #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Cloudflare Workers | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy to Cloudflare Workers | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Create wrangler.toml dynamically | |
run: | | |
cat <<EOF > wrangler.toml | |
name = "${{ secrets.PROJECT_NAME }}" | |
main = "src/index.ts" | |
compatibility_date = "2024-11-20" | |
compatibility_flags = ["nodejs_compat"] | |
[[d1_databases]] | |
binding = "DB" | |
database_name = "${{ secrets.D1_DATABASE_NAME }}" | |
database_id = "${{ secrets.D1_DATABASE_ID }}" | |
migrations_dir = "./src/migrations" | |
EOF | |
- name: Run Tests, Migrations and Deploy using Cloudflare CLI environment | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
preCommands: | | |
pnpm test | |
pnpm migration:prod | |