Bash.tv → GitHub → itch.io

Set up and run automatic deploys from a Bash space to itch.io through GitHub Actions. The bot exports the finished web game into the repo's www/ folder and commits it, directly to main (which deploys the real game) or as a pull request (which deploys a preview page). The GitHub Actions push to itch.io with butler on their own, and the bot verifies the new build. Use for "deploy to itch with Git...

Download skill (.zip) Files on GitHub

Bash → GitHub Actions → itch.io

The flow: make the game in Bash → export it into www/ and commit → a GitHub Action runs butler on its own → itch.io updates. Nothing is pushed to itch.io from Bash directly: the commit is the trigger.

Two paths:

User says Run Action that fires itch.io result
“export / deploy the game” scripts/export-to-www.sh <build> deploy-itch.yml (push to main) Real game updates
“as a pull request”, “for review”, “preview first” scripts/export-to-www.sh <build> --pr deploy-itch-preview.yml (PR) Preview page updates, link commented on the PR. Merging runs deploy-itch.yml

Templates: assets/deploy-itch.yml, assets/deploy-itch-preview.yml, scripts/export-to-www.sh. Copy them as-is; their comments are the user-facing docs. If the repo already has them, use those.

The keys are never visible to the bot. Bash adds the GitHub key to the bot’s GitHub requests, and GitHub adds the itch.io key to the action. Never ask the user to paste a key into chat.

0. Check what’s connected

curl -s "$BASHTV_EGRESS_URL/"   # look for hosts github.com/api.github.com and api.itch.io

1. Token permissions this needs

Repo permission Level Why If missing
Contents Read and write Commit www/ Nothing works
Workflows Read and write Push .github/workflows/* Push is rejected: “refusing to allow a Personal Access Token to create or update workflow … without workflow scope”
Variables Read and write Set ITCH_USER / ITCH_GAME / ITCH_PREVIEW_GAME The user sets them by hand
Pull requests Read and write --pr opens the PR Branch is pushed; the user opens the PR from GitHub’s banner
Actions Read-only Read run status and logs Verify through butler instead

To check without changing anything:

R=https://api.github.com/repos/OWNER/REPO
curl -s -o /dev/null -w "variables %{http_code}\n" $R/actions/variables   # 200 = ok
curl -s -o /dev/null -w "actions %{http_code}\n"   $R/actions/runs        # 200 = ok

You can’t test Workflows ahead of time. Find out when you push. If it’s rejected, keep the local commit, tell the user how to add Workflows: Read and write (GitHub → Settings → Developer settings → Fine-grained tokens → the token → Edit → Repository permissions → Update), and push again once they confirm.

2. Put the game in www/

3. Add the workflows and the export script

mkdir -p .github/workflows scripts
cp <skill-dir>/assets/deploy-itch.yml .github/workflows/
cp <skill-dir>/assets/deploy-itch-preview.yml .github/workflows/
cp <skill-dir>/scripts/export-to-www.sh scripts/ && chmod +x scripts/export-to-www.sh

The preview workflow runs on pull requests into main that touch www/**. It pushes to $ITCH_USER/$ITCH_PREVIEW_GAME:html5 with version pr<N>-<sha>, and posts or updates one PR comment with the link. If ITCH_PREVIEW_GAME isn’t set, it skips and never falls back to the real game. PRs from forks are skipped, because they get no secrets. The preview page must be a separate itch.io game, ideally a Draft, and it needs the same one-time HTML settings (step 7). The bot can’t create itch.io pages, so ask the user to make one.

What it does: it triggers on pushes to main that touch www/**, and has a manual Run workflow button. It reads secret ITCH_IO_API_KEY into BUTLER_API_KEY and variables ITCH_USER, ITCH_GAME, ITCH_CHANNEL (default html5). It checks all of them, installs butler from broth.itch.zone, runs butler push www $ITCH_USER/$ITCH_GAME:$ITCH_CHANNEL --userversion <short sha>, then butler status.

The username and game live in repo variables, never hardcoded in the file, so the code shows no personal info. If the repo’s default branch isn’t main, edit branches:.

4. Settings in GitHub

Secret (the user must add it; the bot never has the key): Repo → Settings → Secrets and variables → Actions → Secrets → New repository secret → Name ITCH_IO_API_KEY, Secret = their itch.io API key (https://itch.io/user/settings/api-keys) → Add secret. You can’t read secrets. A 403 on /actions/secrets is normal with a fine-grained token.

Variables (set them if the token allows; otherwise give the user these exact names):

R=https://api.github.com/repos/OWNER/REPO/actions/variables
for kv in "ITCH_USER user" "ITCH_GAME game" "ITCH_PREVIEW_GAME game-preview"; do set -- $kv
  c=$(curl -s -o /dev/null -w "%{http_code}" -X POST $R -d "{\"name\":\"$1\",\"value\":\"$2\"}")
  [ "$c" = 409 ] && c=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH $R/$1 -d "{\"name\":\"$1\",\"value\":\"$2\"}")
  echo "$1 $c"; done   # 201 created, 204 updated

5. Export and deploy

Build the game first, if it has a build step. Then, from the repo:

scripts/export-to-www.sh <build-folder> --dry-run          # optional: see what changes
scripts/export-to-www.sh <build-folder> -m "Deploy <what changed>"        # main → real game
scripts/export-to-www.sh <build-folder> --pr -m "<what changed>"          # PR → preview page

The script replaces www/ with the build. It drops .git, node_modules, .env*, *.map and logs, checks for index.html and itch.io’s limits, warns about absolute /paths, and exits with “nothing to deploy” if there are no changes. Then it commits and pushes to main, or creates an export/<timestamp> branch, opens a PR through the GitHub API (needs Pull requests: Read and write on the token), and switches back to main.

Ask before a main export to a game that’s already public. The build goes live immediately. (curl -s https://api.itch.io/profile/games shows published.) The --pr path is the safe default whenever the user wants review. Give them the PR link, and remind them that merging makes it live. Only merge if they ask.

A push that doesn’t change www/ won’t deploy. To redeploy without changes, use Run workflow. Via API, that needs Actions: Read and write: curl -X POST $R/actions/workflows/deploy-itch.yml/dispatches -d '{"ref":"main"}'.

6. Verify. Don’t claim success until this passes

The build version is the commit’s short SHA, so match it:

SHA=$(git rev-parse --short HEAD)
# With the itch.io key in Bash (butler installed per the bash-itchio-packager skill):
BUTLER_API_KEY=placeholder ~/bin/butler status USER/GAME:html5   # VERSION column == $SHA, BUILD has ✓
# PR previews: same check on the preview page; the version looks like pr<N>-<sha>
BUTLER_API_KEY=placeholder ~/bin/butler status USER/GAME-PREVIEW:html5
# With Actions: Read-only on the token:
curl -s "https://api.github.com/repos/OWNER/REPO/actions/runs?per_page=1" | grep -E '"(status|conclusion|head_sha)"'

Runs usually take 30–90 seconds. Poll a few times with sleep. If neither check is possible, tell the user to look at the repo’s Actions tab for a green ✓.

Then check the public page, if the game is public. https://USER.itch.io/GAME should contain html-classic.itch.zone/html/...index.html and Run game. If it only shows Download, the user still has to do the one-time page settings.

7. One-time itch.io page settings (the API can’t do these)

After the first deploy, tell the user to open Edit game and:

  1. Kind of project → HTML. The next checkbox only appears after this.
  2. Uploads → on the html5 file, check This file will be played in the browser.
  3. Optionally, Embed options: set the viewport size and turn on the fullscreen button.
  4. Save.

Every later deploy updates the page automatically.

Failure guide

Run log / symptom Cause Fix
Missing secret ITCH_IO_API_KEY Secret not added or misnamed The user adds it (step 4)
Missing variable ITCH_USER/ITCH_GAME Variables not set Set them (step 4)
www/index.html is missing Wrong folder layout Move the build so index.html is at the top of www/
butler invalid key / 401 Wrong or revoked itch.io key The user updates the secret
butler not found for the game Typo in ITCH_USER/ITCH_GAME, or the key belongs to another account Fix the variables
The action never ran Push didn’t touch www/**, branch isn’t main, or Actions disabled Use Run workflow or check repo Settings → Actions
No preview comment on the PR ITCH_PREVIEW_GAME not set (action skipped), the PR is from a fork, or the PR didn’t touch www/ Set the variable, or push a www/ change to the PR branch
GH013: Repository rule violations / “must be made through a pull request” on push to main Branch ruleset requires PRs Don’t try to bypass. Run export-to-www.sh <build> --pr instead and tell the user. Check rules with curl -s https://api.github.com/repos/OWNER/REPO/rules/branches/main
itch.io page shows Download only Page settings not done Step 7
The game loads blank on itch.io Absolute /paths or missing files Use relative paths. Test www/ served from a subfolder

Handoff

Keep it short: say whether the build is live (version = commit), give the itch.io page, and list only what the user still has to do (secret, token permission, page settings). Never include keys, and avoid repeating the user’s username or IDs in shared docs. Use yourname/my-game in examples.