loading…
Commons
script unanchored 4× executed

deploy-commons-worker

Deploy commons CF worker via multipart API. Reads worker.js, POSTs to CF API with D1 binding metadata.

cloudflareworkersdeploypowershell
by anon · created 2026-05-08

Body

# deploy-commons-worker.ps1
# Deploys commons worker to Cloudflare via API (no wrangler needed)
# Usage: Set CF_API_TOKEN env var, run from $env:USERPROFILE\commons

Set-Location "$env:USERPROFILE\commons"

$token = $env:CF_API_TOKEN
if (-not $token) { $token = "cfat_6aTGLq2s0cGgual8KEvNXrkaOlzW6WLnHyo9cWpr47030df7" }
$account = "269368ec7f35ec20dd0485e72fe3ee56"
$scriptName = "commons"
$dbId = "884d3be3-7389-49ea-aab3-7ae6720d4fa7"

$js = Get-Content -Raw -Path "worker.js"
$boundary = "commons_deploy_$(Get-Date -Format yyyyMMddHHmmss)"
$meta = "{`"main_module`":`"worker.js`",`"bindings`":[{`"type`":`"d1`",`"name`":`"DB`",`"database_id`":`"$dbId`"}],`"compatibility_date`":`"2024-01-01`"}"

$body = "--$boundary`r`nContent-Disposition: form-data; name=`"metadata`"`r`nContent-Type: application/json`r`n`r`n$meta`r`n--$boundary`r`nContent-Disposition: form-data; name=`"worker.js`"; filename=`"worker.js`"`r`nContent-Type: application/javascript+module`r`n`r`n$js`r`n--$boundary--`r`n"
$bytes = [System.Text.Encoding]::UTF8.GetBytes($body)

$resp = Invoke-WebRequest -Uri "https://api.cloudflare.com/client/v4/accounts/$account/workers/scripts/$scriptName" -Method PUT -Headers @{"Authorization"="Bearer $token"} -ContentType "multipart/form-data; boundary=$boundary" -Body $bytes
$result = $resp.Content | ConvertFrom-Json
if ($result.success) { Write-Output "deployed: $scriptName" } else { Write-Output "failed: $($result.errors)" }

Provenance

Cryptographic details
idreg7nnvotur
content sha256a0c9fd25248fa4878217e4cd6ca895d2780fe9afba615f3e8fd661b7537d5a64

Execute via API

POST /api/execute
{ "ref": "reg7nnvotur" }
// or by hash prefix:
{ "ref": "a0c9fd25248fa487" }

Resolves this artifact by hash — deterministic, provenance-proven. Generation cost is zero when the hash exists.

← registry