Bash.tv → GitHub → itch.io

← Services · Home

Cloudflare Pages: Host the Game on Its Own Website

Cloudflare Pages gives your game a free, fast web address like my-game.pages.dev, with no itch.io page around it. You can also connect your own domain.

   
Cost Free plan: unlimited sites and bandwidth, 500 builds a month
Upload from Bash / GitHub Actions? ✅ Both, with Cloudflare’s wrangler tool
Needs a Bash API key? Only to deploy from Bash. GitHub Actions uses its own secret
Good for A clean link to share, your own domain, a “real website” version of the game

Part 1: Account and project

  1. Sign up at https://dash.cloudflare.com/sign-up.
  2. Copy your Account ID: dashboard → Workers & Pages → it’s shown on the right side (or in the URL: dash.cloudflare.com/<account-id>/...).
  3. Pick a project name, like my-game. It becomes my-game.pages.dev. The first deploy creates the project if it doesn’t exist.

Part 2: Create an API token

  1. Go to https://dash.cloudflare.com/profile/api-tokens → Create Token → Create Custom Token.
  2. Token name: Bash Pages deploy
  3. Permissions: Account → Cloudflare Pages → Edit
  4. Account Resources: Include → your account
  5. Continue to summary → Create Token → copy it. It’s only shown once.

Part 3a: Deploy from Bash

Add the key in Bash: gear icon → API keys → Any API

Field Value
Address api.cloudflare.com
Name Cloudflare
Key your API token
How it’s sent Bearer token
Tips for the bot Cloudflare Pages token. Account ID <id>. Deploy www/ to project my-game with wrangler pages deploy.

Then ask the bot:

Deploy www/ to Cloudflare Pages project my-game.

The bot runs:

CLOUDFLARE_API_TOKEN=placeholder CLOUDFLARE_ACCOUNT_ID=<id> \
  npx wrangler pages deploy www --project-name=my-game --branch=main

Part 3b: Deploy from GitHub Actions (on every www/ change)

  1. Repo → Settings → Secrets and variables → Actions
    • Secrets: CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID
    • Variable: CLOUDFLARE_PROJECT = my-game
  2. Add .github/workflows/deploy-cloudflare.yml:
name: Deploy to Cloudflare Pages
on:
  push:
    branches: [main]
    paths: ["www/**"]
  pull_request:
    paths: ["www/**"]       # pull requests get their own preview URL
  workflow_dispatch:
jobs:
  deploy:
    runs-on: ubuntu-latest
    if: $
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
      - uses: cloudflare/wrangler-action@v3
        with:
          apiToken: $
          accountId: $
          command: pages deploy www --project-name=$ --branch=$

Pushes to main update my-game.pages.dev. Pull requests get a separate preview link, like <branch>.my-game.pages.dev.


Troubleshooting

Problem Fix
Authentication error [code: 10000] The token needs Account → Cloudflare Pages → Edit for the right account.
Project not found Check the project name, or create it once in the dashboard (Workers & Pages → Create → Pages → Direct Upload).
Old version still showing Cloudflare caches for a moment. Hard refresh, or open the unique deploy URL wrangler prints.
Game blank Use relative paths (./game.js). index.html must be at the top of www/.

Checklist