Mastro 👨‍🍳 Docs

Search results

Blog GitHub   Bluesky

Build static site with Deno and deploy to Cloudflare

← Other deployment options

To host your static site on Cloudflare, we need a wrangler.json config:

wrangler.json
{
  "name": "my-static-page",
  "compatibility_date": "2025-08-23",
  "assets": {
    "directory": "./generated"
  }
}
Copied!

After adding that to your GitHub repo, go to the Cloudflare Dashboard, click Create application, choose Import a repository, and follow the instructions.

To create the generated folder, you can either build and deploy in Cloudflare, or in GitHub Actions.

Cloudflare build

Build command

curl -fsSL https://deno.land/x/install/install.sh | sh && /opt/buildhome/.deno/bin/deno task generate
Copied!

Deploy command

npx wrangler deploy
Copied!

GitHub Actions

Alternatively, add your credentials (CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN) to GitHub secrets, and add the following file to your GitHub repository:

.github/workflows/deploy.yml
name: Deploy Site

on:
  push:
    branches: [ main ]

permissions:
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Install Deno
        uses: denoland/setup-deno@v2
        with:
          deno-version: v2.x

      - name: Build static site
        run: deno task generate

      - name: Deploy to Cloudflare Workers
        uses: cloudflare/wrangler-action@v3
        with:
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          command: deploy --config wrangler.json
Copied!

Congratulations!

Pushing to GitHub should now deploy your static site to Cloudflare.