Skip to content

Christopher Bennell

I build web stuff. Full Stack/Platform Engineering/Architecture. Senior Software Engineer.

A Tangled.org Deploy Script for Cloudflare

• 4 min read A Tangled.org Deploy Script for Cloudflare

Tangled.org is an AT Protocol-powered git collaboration platform. It’s like GitHub, without the bloat and Copilot shoehorned in every corner.

I’ve been doing some experiments building ATProto tools, and sampling the ecosystem, and I’ve been eager to explore Tangled. I’ve been equally eager to migrate some of my content away from GitHub, as it has been increasingly unreliable and unpleasant to use.

I host a lot of my static content on Cloudflare Workers (formerly “Pages”), and I rely on CI process triggered by git operations to build and deploy to Cloudflare. Cloudflare has tight integration with GitHub, which gives you deploy-on-push and preview environments out of the box. To get that kind of integration with Tangled, we do a bit more work.

Fortunately, the Tangled CI config is quite straightforward. I’ve set up Tangled CI configs to deploy to production when I push to main, and to create Cloudflare preview environments when I create Tangled pull requests.

Prerequisites

For this to work, we need a few things.

1. Add Wrangler to package.json

First, we add Cloudflare’s CLI tool, wrangler, to the project dependencies (not devDependencies), so it will get installed with the other packages requied for the build.

npm install wranger
# Or
yarn add wranger

2. CI Secrets

We need to authenticate to Cloudflare using an API key and account ID. The Cloudflare docs explain where to find these values. Of course, we can’t commit these values to the repo, so we store them as Tangled pipeline secrets. You can create these in the Tangled repo settings page, on the “pipelines” section. They are injected as environment variables in the CI build. Wranger will look for variables named CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN, so this is what you should name your secrets.

3. Cloudflare Workers Project and Wrangler Config

If you don’t have one already, create a Cloudflare Workers application. Cloudflare has deprecated its “Pages” tool, which was the preferred method for hosting static assets. You can get the same functionality (with the same free price tier) from Workers.

Add a wrangler.jsonc file to your project with some basic configuration. Here’s mine. It assumes our build process will output to ./dist. The name field should match the name of your Worker application.

{
"name": "cbennell-com",
"compatibility_date": "2026-05-02",
"assets": {
"directory": "./dist",
"not_found_handling": "404-page"
},
"preview_urls": true
}

wranger.jsonc

The scripts

Deploy to Production

when:
- event: ["push", "manual"]
branch: ["main"]
engine: "nixery"
dependencies:
nixpkgs:
- nodejs
steps:
- name: "Install dependencies"
command: "npm ci"
- name: "Build"
command: "npm run build"
environment:
NODE_ENV: "production"
- name: "Login to Cloudflare"
command: "npx wrangler login"
- name: "Deploy"
command: "npx wrangler deploy"

.tangled/workflows/deploy.yml

Deploy Preview Enviroment for Pull Requests

when:
- event: ["pull_request"]
branch: ["main"]
engine: "nixery"
dependencies:
nixpkgs:
- nodejs
steps:
- name: "Install dependencies"
command: "npm ci"
- name: "Build"
command: "npm run build"
environment:
NODE_ENV: "production"
- name: "Login to Cloudflare"
command: "npx wrangler login"
- name: "Deploy"
command: "npx wrangler versions upload --preview-alias ${TANGLED_PR_SOURCE_BRANCH}"

.tangled/workflows/deploy_preview.yml

If you prefer Yarn, add it as an additional nixpkgs dependency and change the npm commands to yarn equivalents.

when:
- event: ["push", "manual"]
branch: ["main"]
engine: "nixery"
dependencies:
nixpkgs:
- nodejs
- yarn
steps:
- name: "Install dependencies"
command: "yarn install --frozen-lockfile"
- name: "Build"
command: "yarn run build"
environment:
NODE_ENV: "production"
- name: "Login to Cloudflare"
command: "yarn wrangler login"
- name: "Deploy"
command: "yarn wrangler deploy"

.tangled/workflows/deploy.yml

Bonus Tip

A cool feature of Tangled is that when you push commits that trigger CI runs, the remote will reply with a SSH command you can run to watch the CI log, right in your terminal.

The Future?

I’m not yet certain how much I will be migrating away from GitHub. There’s some stuff that still needs to live there, and it’s not ideal to have my work scattered across platforms. This is an experiment, to learn about the experience.

Tangled.org is not even a year-and-a-half old at the time I’m writing this. I’m not certain it will emerge as the successor to GitHub, and there are other platforms, like CodeBerg that are getting some attention. We will see what happens. But ATProto is such an exciting technology. I’m really enjoying watching it develop, and I’ll have more to say about this soon.