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.
10 files changed+32−13
Files (10)
- .github/workflows/awesome-lists.yml+1−1
- .github/workflows/ci.yml+6−2
- .github/workflows/d1-replication.yml+2−2
- .github/workflows/deploy.yml+5−2
- .github/workflows/e2e.yml+4−3
- .github/workflows/github-community.yml+1−1
- .github/workflows/live-test.yml+1−1
- .github/workflows/mirror-to-github.yml+1−1
- apps/diffinery/docs/actions/github-runners.md+10−0
- apps/diffinery/docs/self-hosting/deploy.md+1−0
modified.github/workflows/awesome-lists.yml+1−1View file
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | suggest: |
| 27 | 27 | name: Open the list pull requests |
| 28 | 28 | 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' }} | |
| 30 | 30 | environment: github-mirror |
| 31 | 31 | timeout-minutes: 10 |
| 32 | 32 | steps: |
modified.github/workflows/ci.yml+6−2View file
| @@ -2,6 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | # Deploy waits for this workflow to pass on main. The end-to-end suite is its own |
| 4 | 4 | # 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. | |
| 5 | 9 | |
| 6 | 10 | on: |
| 7 | 11 | push: |
| @@ -20,7 +24,7 @@ | ||
| 20 | 24 | # tests together took longer than either does alone. |
| 21 | 25 | typecheck: |
| 22 | 26 | name: Typecheck and bundle |
| 23 | - runs-on: ubuntu-latest | |
| 27 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 24 | 28 | timeout-minutes: 20 |
| 25 | 29 | steps: |
| 26 | 30 | - uses: actions/checkout@v4 |
| @@ -40,7 +44,7 @@ | ||
| 40 | 44 | |
| 41 | 45 | test: |
| 42 | 46 | name: Unit tests (${{ matrix.shard }}/2) |
| 43 | - runs-on: ubuntu-latest | |
| 47 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 44 | 48 | timeout-minutes: 20 |
| 45 | 49 | # Two halves of every package's test files, side by side: CI is the first step of a deploy. |
| 46 | 50 | strategy: |
modified.github/workflows/d1-replication.yml+2−2View file
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | jobs: |
| 19 | 19 | check: |
| 20 | 20 | name: Check sessions on a test database |
| 21 | - runs-on: ubuntu-latest | |
| 21 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 22 | 22 | # The Cloudflare secrets are the production environment's. |
| 23 | 23 | environment: production |
| 24 | 24 | timeout-minutes: 20 |
| @@ -81,7 +81,7 @@ | ||
| 81 | 81 | name: Turn on read replication in production |
| 82 | 82 | needs: check |
| 83 | 83 | if: ${{ inputs.enable_production }} |
| 84 | - runs-on: ubuntu-latest | |
| 84 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 85 | 85 | environment: |
| 86 | 86 | name: production |
| 87 | 87 | url: https://${{ vars.DIFFINERY_DOMAIN || 'diffinery.com' }} |
modified.github/workflows/deploy.yml+5−2View file
| @@ -9,6 +9,9 @@ | ||
| 9 | 9 | # ACCESS_TEAM_DOMAIN e.g. example.cloudflareaccess.com |
| 10 | 10 | # DIFFINERY_GITHUB_APP_ID, DIFFINERY_GITHUB_APP_SLUG, DIFFINERY_GITHUB_APP_CLIENT_ID, |
| 11 | 11 | # 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. | |
| 12 | 15 | # |
| 13 | 16 | # It deploys a main commit only once CI (typecheck, unit tests and the Worker bundle) has |
| 14 | 17 | # passed on it, so it doesn't run those itself. End-to-end tests run alongside the deploy. |
| @@ -37,7 +40,7 @@ | ||
| 37 | 40 | # Every push to main deploys once CI passes on it, on GitHub or on a Diffinery |
| 38 | 41 | # instance, and so does running this workflow by hand. |
| 39 | 42 | 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' }} | |
| 41 | 44 | timeout-minutes: 5 |
| 42 | 45 | outputs: |
| 43 | 46 | deploy: ${{ steps.tip.outputs.deploy }} |
| @@ -67,7 +70,7 @@ | ||
| 67 | 70 | name: Deploy to Cloudflare |
| 68 | 71 | needs: gate |
| 69 | 72 | if: ${{ needs.gate.outputs.deploy == 'true' }} |
| 70 | - runs-on: ubuntu-latest | |
| 73 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 71 | 74 | timeout-minutes: 45 |
| 72 | 75 | environment: |
| 73 | 76 | name: production |
modified.github/workflows/e2e.yml+4−3View file
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | # Only the last shard needs a browser (passkeys). |
| 20 | 20 | e2e: |
| 21 | 21 | name: End-to-end (${{ matrix.name }}) |
| 22 | - runs-on: ubuntu-latest | |
| 22 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 23 | 23 | timeout-minutes: 20 |
| 24 | 24 | strategy: |
| 25 | 25 | fail-fast: false |
| @@ -87,11 +87,12 @@ | ||
| 87 | 87 | node --test --test-concurrency=2 "${opts[@]}" $files |
| 88 | 88 | |
| 89 | 89 | # 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. | |
| 91 | 92 | # A daemon an earlier step started is stopped first, so the first uses below start it afresh. |
| 92 | 93 | runner-docker: |
| 93 | 94 | name: End-to-end (runner Docker) |
| 94 | - runs-on: ubuntu-latest | |
| 95 | + runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} | |
| 95 | 96 | timeout-minutes: 20 |
| 96 | 97 | steps: |
| 97 | 98 | - uses: actions/checkout@v4 |
modified.github/workflows/github-community.yml+1−1View file
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | setup: |
| 20 | 20 | name: Labels, welcome discussion and roadmap issue |
| 21 | 21 | 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' }} | |
| 23 | 23 | environment: github-mirror |
| 24 | 24 | timeout-minutes: 5 |
| 25 | 25 | steps: |
modified.github/workflows/live-test.yml+1−1View file
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | name: Containers, registry, sandboxes, webhooks, schedules, LFS and pull requests |
| 32 | 32 | # Runs on the host that deploys production (see the gate in deploy.yml). |
| 33 | 33 | 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' }} | |
| 35 | 35 | timeout-minutes: 45 |
| 36 | 36 | environment: production |
| 37 | 37 | env: |
modified.github/workflows/mirror-to-github.yml+1−1View file
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | mirror: |
| 25 | 25 | name: Push main to the GitHub mirror |
| 26 | 26 | 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' }} | |
| 28 | 28 | environment: github-mirror |
| 29 | 29 | timeout-minutes: 10 |
| 30 | 30 | env: |
modifiedapps/diffinery/docs/actions/github-runners.md+10−0View file
| @@ -62,6 +62,16 @@ | ||
| 62 | 62 | - 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. |
| 63 | 63 | - Matrix legs each get their own runner. |
| 64 | 64 | |
| 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 | + | |
| 65 | 75 | ## The machine |
| 66 | 76 | |
| 67 | 77 | 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 @@ | ||
| 111 | 111 | | `MAIL_DOMAIN` | Variable, optional | The domain email is sent from, when it isn't `DIFFINERY_DOMAIN`. | |
| 112 | 112 | | `ACCESS_TEAM_DOMAIN` | Variable, optional | Your Zero Trust team domain, for example `example.cloudflareaccess.com`. Needed only when the token can't read it. | |
| 113 | 113 | | `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 | 115 | |
| 115 | 116 | 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. |
| 116 | 117 |