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 fork pull requests' CI on Diffinery's runners, not GitHub's

GitHub passes no repository variables to pull requests from forks, so DIFFINERY_RUNS_ON
was empty there and every job fell back to ubuntu-latest on GitHub's own runners. In
codician-team/diffinery, default the label to `diffinery` instead; the variable still
overrides it, and other copies of the repository keep ubuntu-latest. With that the
runner Docker job runs on fork pull requests too, so it no longer needs skipping there.
Alan Kernel authored 1 parent 57fb7c2commit e27e2a2383568ff46aebc39a82cce5ce054e80dbBrowse files
10 files changed+34−26
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: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
29+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
3030 environment: github-mirror
3131 timeout-minutes: 10
3232 steps:
modified.github/workflows/ci.yml+6−4View file
@@ -4,8 +4,10 @@
44 # workflow (e2e.yml), so deploys don't wait for it too.
55 #
66 # 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.
7+# DIFFINERY_RUNS_ON, else on `diffinery` (diffinery.com's GitHub runners) in
8+# codician-team/diffinery, else ubuntu-latest (a hosted runner on Diffinery too). GitHub passes
9+# no variables to pull requests from forks, so without that middle default they would run on
10+# GitHub's own runners. Other copies of the repository need nothing.
911
1012 on:
1113 push:
@@ -24,7 +26,7 @@
2426 # tests together took longer than either does alone.
2527 typecheck:
2628 name: Typecheck and bundle
27- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
29+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
2830 timeout-minutes: 20
2931 steps:
3032 - uses: actions/checkout@v4
@@ -44,7 +46,7 @@
4446
4547 test:
4648 name: Unit tests (${{ matrix.shard }}/2)
47- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
49+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
4850 timeout-minutes: 20
4951 # Two halves of every package's test files, side by side: CI is the first step of a deploy.
5052 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: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
21+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || '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: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
84+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
8585 environment:
8686 name: production
8787 url: https://${{ vars.DIFFINERY_DOMAIN || 'diffinery.com' }}
modified.github/workflows/deploy.yml+5−4View file
@@ -10,8 +10,9 @@
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)
1212 # 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.
13+# ubuntu-latest, and `diffinery` in codician-team/diffinery, whose fork pull
14+# requests get no variables). `diffinery` runs them on a Diffinery instance's
15+# GitHub runners; set it back to ubuntu-latest to deploy while those can't start.
1516 #
1617 # It deploys a main commit only once CI (typecheck, unit tests and the Worker bundle) has
1718 # passed on it, so it doesn't run those itself. End-to-end tests run alongside the deploy.
@@ -42,7 +43,7 @@
4243 # codician/diffinery, an older copy of this repository: GitHub deploys diffinery.com,
4344 # and that copy lacks the GitHub App's variables a deploy needs.
4445 if: ${{ !(github.server_url == 'https://diffinery.com' && github.repository == 'codician/diffinery') && (github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push')) }}
45- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
46+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
4647 timeout-minutes: 5
4748 outputs:
4849 deploy: ${{ steps.tip.outputs.deploy }}
@@ -72,7 +73,7 @@
7273 name: Deploy to Cloudflare
7374 needs: gate
7475 if: ${{ needs.gate.outputs.deploy == 'true' }}
75- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
76+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
7677 timeout-minutes: 45
7778 environment:
7879 name: production
modified.github/workflows/e2e.yml+3−6View 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: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
22+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
2323 timeout-minutes: 20
2424 strategy:
2525 fail-fast: false
@@ -88,14 +88,11 @@
8888
8989 # Docker as the hosted runner image runs it, with this change's docker wrapper, daemon config
9090 # 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.
92- # Pull requests from forks get no repository variables, so they would land on GitHub's runners:
93- # they skip the job, and a maintainer runs it by pushing the branch to this repository.
91+ # Diffinery, or on GitHub on the `diffinery` label. On GitHub's own runners it fails.
9492 # A daemon an earlier step started is stopped first, so the first uses below start it afresh.
9593 runner-docker:
9694 name: End-to-end (runner Docker)
97- if: ${{ !github.event.pull_request.head.repo.fork }}
98- runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
95+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
9996 timeout-minutes: 20
10097 steps:
10198 - 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: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
22+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || '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: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }}
34+ runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }}
3535 timeout-minutes: 45
3636 environment: production
3737 env:
modifiedCONTRIBUTING.md+5−5View file
@@ -57,11 +57,11 @@
5757 end-to-end shards before they merge. Tests must not depend on the speed of the machine
5858 they run on.
5959
60-The "End-to-end (runner Docker)" job needs one of Diffinery's own runners, which GitHub
61-picks through the repository variable `DIFFINERY_RUNS_ON`. GitHub doesn't pass repository
62-variables to pull requests from forks, so on a fork's pull request that job is skipped,
63-not failed. If your change touches the runner's Docker support (`containers/runner`), a
64-maintainer runs the job by pushing your branch to this repository.
60+CI runs on Diffinery's own runners for GitHub (`runs-on: diffinery`), pull requests from
61+forks included: in this repository the workflows default to that label when the
62+repository variable `DIFFINERY_RUNS_ON`, which GitHub doesn't pass to forks, is missing.
63+The "End-to-end (runner Docker)" job needs those runners and fails on GitHub's own. A
64+maintainer may have to approve the workflows of your first pull request before they run.
6565
6666 ## Conventions
6767
modifiedapps/diffinery/docs/actions/github-runners.md+9−1View file
@@ -70,8 +70,16 @@
7070 runs-on: ${{ vars.RUNS_ON || 'ubuntu-latest' }}
7171 ```
7272
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`.
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.
7474
75+GitHub passes no repository variables to workflows of pull requests from forks, so those jobs run on `ubuntu-latest` too. To run them on Diffinery as well, default to `diffinery` in your own repository, and keep `ubuntu-latest` for copies of it:
76+
77+```yaml
78+ runs-on: ${{ vars.RUNS_ON || (github.repository == 'my-org/my-repo' && 'diffinery') || 'ubuntu-latest' }}
79+```
80+
81+Diffinery's own repository does this with `DIFFINERY_RUNS_ON`. Read [Security](#security) first: anyone who opens a pull request can then use your minutes.
82+
7583 ## The machine
7684
7785 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−1View file
@@ -111,7 +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. |
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` (in `codician-team/diffinery` itself, on `diffinery`, so pull requests from forks, which get no variables, run there too). 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. |
115115
116116 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.
117117