Diffinery

homeflare/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

Run this repository's workflows on the label in DIFFINERY_RUNS_ON

Every job's runs-on is now vars.DIFFINERY_RUNS_ON, else ubuntu-latest. The
GitHub copy sets it to `diffinery`, so its CI, end-to-end tests and deploys
run on diffinery.com's GitHub runners. Forks without the variable keep
running on GitHub, so deploying your own instance still needs no workflow
changes, and setting the variable back to ubuntu-latest deploys a fix while
Diffinery can't start runners. On Diffinery itself, ubuntu-latest and
diffinery are both hosted labels.

The end-to-end runner Docker job, which needs a Diffinery hosted runner,
now passes on GitHub too once the variable is set.
altug authored 1 parent a8c69ddcommit 8e4cb8566dfea7010aecc194156f3c23ab99f331Browse files
10 files changed+32−13
Files (10)
modified.github/workflows/awesome-lists.yml+1−1View file
@@ -26,7 +26,7 @@
2626 suggest:
2727 name: Open the list pull requests
2828 if: ${{ github.server_url != 'https://github.com' && github.repository == 'codician/diffinery' }}
29- runs-on: ubuntu-latest
29+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
3030 environment: github-mirror
3131 timeout-minutes: 10
3232 steps:
modified.github/workflows/ci.yml+6−2View file
@@ -2,6 +2,10 @@
22
33 # Deploy waits for this workflow to pass on main. The end-to-end suite is its own
44 # workflow (e2e.yml), so deploys don't wait for it too.
5+#
6+# Every job of this repository's workflows runs on the label in the repository variable
7+# DIFFINERY_RUNS_ON, else ubuntu-latest (a hosted runner on Diffinery too). The GitHub copy
8+# sets `diffinery` to run on diffinery.com's GitHub runners; forks need nothing.
59
610 on:
711 push:
@@ -20,7 +24,7 @@
2024 # tests together took longer than either does alone.
2125 typecheck:
2226 name: Typecheck and bundle
23- runs-on: ubuntu-latest
27+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
2428 timeout-minutes: 20
2529 steps:
2630 - uses: actions/checkout@v4
@@ -40,7 +44,7 @@
4044
4145 test:
4246 name: Unit tests (${{ matrix.shard }}/2)
43- runs-on: ubuntu-latest
47+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
4448 timeout-minutes: 20
4549 # Two halves of every package's test files, side by side: CI is the first step of a deploy.
4650 strategy:
modified.github/workflows/d1-replication.yml+2−2View file
@@ -18,7 +18,7 @@
1818 jobs:
1919 check:
2020 name: Check sessions on a test database
21- runs-on: ubuntu-latest
21+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
2222 # The Cloudflare secrets are the production environment's.
2323 environment: production
2424 timeout-minutes: 20
@@ -81,7 +81,7 @@
8181 name: Turn on read replication in production
8282 needs: check
8383 if: ${{ inputs.enable_production }}
84- runs-on: ubuntu-latest
84+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
8585 environment:
8686 name: production
8787 url: https://${{ vars.DIFFINERY_DOMAIN || 'diffinery.com' }}
modified.github/workflows/deploy.yml+5−2View file
@@ -9,6 +9,9 @@
99 # ACCESS_TEAM_DOMAIN e.g. example.cloudflareaccess.com
1010 # DIFFINERY_GITHUB_APP_ID, DIFFINERY_GITHUB_APP_SLUG, DIFFINERY_GITHUB_APP_CLIENT_ID,
1111 # DIFFINERY_GITHUB_APP_URL the GitHub App of GitHub runners (docs/self-hosting/configuration.md)
12+# DIFFINERY_RUNS_ON the runner label of every job in this repository's workflows (default
13+# ubuntu-latest). `diffinery` runs them on a Diffinery instance's GitHub runners;
14+# set it back to ubuntu-latest to deploy while those can't start.
1215 #
1316 # It deploys a main commit only once CI (typecheck, unit tests and the Worker bundle) has
1417 # passed on it, so it doesn't run those itself. End-to-end tests run alongside the deploy.
@@ -37,7 +40,7 @@
3740 # Every push to main deploys once CI passes on it, on GitHub or on a Diffinery
3841 # instance, and so does running this workflow by hand.
3942 if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') }}
40- runs-on: ubuntu-latest
43+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
4144 timeout-minutes: 5
4245 outputs:
4346 deploy: ${{ steps.tip.outputs.deploy }}
@@ -67,7 +70,7 @@
6770 name: Deploy to Cloudflare
6871 needs: gate
6972 if: ${{ needs.gate.outputs.deploy == 'true' }}
70- runs-on: ubuntu-latest
73+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
7174 timeout-minutes: 45
7275 environment:
7376 name: production
modified.github/workflows/e2e.yml+4−3View file
@@ -19,7 +19,7 @@
1919 # Only the last shard needs a browser (passkeys).
2020 e2e:
2121 name: End-to-end (${{ matrix.name }})
22- runs-on: ubuntu-latest
22+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
2323 timeout-minutes: 20
2424 strategy:
2525 fail-fast: false
@@ -87,11 +87,12 @@
8787 node --test --test-concurrency=2 "${opts[@]}" $files
8888
8989 # Docker as the hosted runner image runs it, with this change's docker wrapper, daemon config
90- # and agent (its registry relay): this job runs on a hosted runner, so the real dockerd is there.
90+ # and agent (its registry relay). It needs a Diffinery hosted runner, for the real dockerd: on
91+ # Diffinery, or on GitHub with DIFFINERY_RUNS_ON=diffinery. On GitHub's own runners it fails.
9192 # A daemon an earlier step started is stopped first, so the first uses below start it afresh.
9293 runner-docker:
9394 name: End-to-end (runner Docker)
94- runs-on: ubuntu-latest
95+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
9596 timeout-minutes: 20
9697 steps:
9798 - uses: actions/checkout@v4
modified.github/workflows/github-community.yml+1−1View file
@@ -19,7 +19,7 @@
1919 setup:
2020 name: Labels, welcome discussion and roadmap issue
2121 if: ${{ github.server_url != 'https://github.com' && github.repository == 'codician/diffinery' }}
22- runs-on: ubuntu-latest
22+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
2323 environment: github-mirror
2424 timeout-minutes: 5
2525 steps:
modified.github/workflows/live-test.yml+1−1View file
@@ -31,7 +31,7 @@
3131 name: Containers, registry, sandboxes, webhooks, schedules, LFS and pull requests
3232 # Runs on the host that deploys production (see the gate in deploy.yml).
3333 if: ${{ github.event_name == 'workflow_dispatch' || (github.server_url == 'https://diffinery.com' && github.event.workflow_run.conclusion == 'success') }}
34- runs-on: ubuntu-latest
34+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
3535 timeout-minutes: 45
3636 environment: production
3737 env:
modified.github/workflows/mirror-to-github.yml+1−1View file
@@ -24,7 +24,7 @@
2424 mirror:
2525 name: Push main to the GitHub mirror
2626 if: ${{ github.server_url != 'https://github.com' && github.repository == 'codician/diffinery' }}
27- runs-on: ubuntu-latest
27+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
2828 environment: github-mirror
2929 timeout-minutes: 10
3030 env:
modifiedapps/diffinery/docs/actions/github-runners.md+10−0View file
@@ -62,6 +62,16 @@
6262 - Diffinery doesn't pick a smaller size by itself for GitHub jobs, as it does for [jobs of Diffinery repositories](/docs/actions/runners#runner-sizes): the label sets the size.
6363 - Matrix legs each get their own runner.
6464
65+### Switch a whole repository with one variable
66+
67+To move every job at once, and to be able to move them back without a commit, read the label from a repository variable:
68+
69+```yaml
70+ runs-on: ${{ vars.RUNS_ON || 'ubuntu-latest' }}
71+```
72+
73+Then set the variable to `diffinery` (`gh variable set RUNS_ON --body diffinery`). Setting it back to `ubuntu-latest` returns the jobs to GitHub-hosted runners, for example to keep a deploy working while Diffinery can't start runners. Forks without the variable keep running on GitHub. Diffinery's own repository does this with `DIFFINERY_RUNS_ON`.
74+
6575 ## The machine
6676
6777 The container runs the same image as Diffinery's own [hosted runners](/docs/actions/runners#hosted-runners): Ubuntu 24.04 on x64 with Git, Node.js 22, Python 3.12, Docker, the GitHub CLI and `/dev/kvm`. Differences from a GitHub-hosted runner:
modifiedapps/diffinery/docs/self-hosting/deploy.md+1−0View file
@@ -111,6 +111,7 @@
111111 | `MAIL_DOMAIN` | Variable, optional | The domain email is sent from, when it isn't `DIFFINERY_DOMAIN`. |
112112 | `ACCESS_TEAM_DOMAIN` | Variable, optional | Your Zero Trust team domain, for example `example.cloudflareaccess.com`. Needed only when the token can't read it. |
113113 | `DIFFINERY_GITHUB_APP_ID`, `DIFFINERY_GITHUB_APP_SLUG`, `DIFFINERY_GITHUB_APP_CLIENT_ID`, `DIFFINERY_GITHUB_APP_URL` | Variables, optional | The GitHub App of [GitHub runners](/docs/self-hosting/configuration#github-runners). The workflow passes them to render-config as `GITHUB_APP_ID` and the rest. |
114+| `DIFFINERY_RUNS_ON` | Variable, optional | The `runs-on` label of every job in the repository's workflows. Without it, jobs run on `ubuntu-latest`. Set it to `diffinery` to run them on a Diffinery instance's [GitHub runners](/docs/actions/github-runners) once that instance's GitHub App is installed on the repository. Set it back to `ubuntu-latest` to deploy while those runners can't start, for example while the instance itself is down. |
114115
115116 The Deploy job runs in an environment named `production`, so you can also store the secrets as environment secrets there and add required reviewers to that environment.
116117