Deploy on GitHub pushes when DEPLOY_ON_PUSH is true
The Deploy workflow only ran on pushes when the repository lived on a Diffinery instance, so a copy that lives on GitHub had to start every deploy by hand. The repository variable DEPLOY_ON_PUSH opts a GitHub copy in; mirrors of a repository that deploys from Diffinery leave it unset so nothing deploys twice.
2 files changed+6−3
modified.github/workflows/deploy.yml+5−2View file
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | # DIFFINERY_ZONE the Cloudflare zone for the route (default: the domain's last two labels) |
| 8 | 8 | # MAIL_DOMAIN sends from notifications@<MAIL_DOMAIN> (default DIFFINERY_DOMAIN) |
| 9 | 9 | # ACCESS_TEAM_DOMAIN e.g. example.cloudflareaccess.com |
| 10 | +# DEPLOY_ON_PUSH "true" deploys every push to main on GitHub too (Diffinery always does) | |
| 10 | 11 | # |
| 11 | 12 | # It deploys a main commit only once CI (typecheck, unit tests and the Worker bundle) has |
| 12 | 13 | # passed on it, so it doesn't run those itself. End-to-end tests run alongside the deploy. |
| @@ -34,8 +35,10 @@ | ||
| 34 | 35 | name: Main's current tip |
| 35 | 36 | # Production deploys from Diffinery itself, on its own hosted runners (any |
| 36 | 37 | # Diffinery, so self-hosted copies deploy themselves too). Running this |
| 37 | - # workflow by hand on GitHub still deploys, as a fallback. | |
| 38 | - if: ${{ github.event_name == 'workflow_dispatch' || (github.server_url != 'https://github.com' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') }} | |
| 38 | + # workflow by hand on GitHub still deploys, as a fallback. On GitHub, pushes to | |
| 39 | + # main deploy only when the repository variable DEPLOY_ON_PUSH is "true", so a | |
| 40 | + # mirror of a repository that deploys elsewhere never deploys twice. | |
| 41 | + if: ${{ github.event_name == 'workflow_dispatch' || ((github.server_url != 'https://github.com' || vars.DEPLOY_ON_PUSH == 'true') && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') }} | |
| 39 | 42 | runs-on: ubuntu-latest |
| 40 | 43 | timeout-minutes: 5 |
| 41 | 44 | outputs: |
modifiedapps/diffinery/docs/self-hosting/deploy.md+1−1View file
| @@ -68,7 +68,7 @@ | ||
| 68 | 68 | - `DIFFINERY_ZONE`, if the Cloudflare zone that holds your hostname is not its last two labels. For `git.example.com` the default zone is `example.com`, which is right; for `git.example.co.uk` the default would be `co.uk`, so set `DIFFINERY_ZONE` to `example.co.uk`. |
| 69 | 69 | - `MAIL_DOMAIN`, if email should come from another domain than your hostname, for example `example.com` to send from `[email protected]`. |
| 70 | 70 | |
| 71 | -The Deploy job runs on every push to `main` when your copy lives on a Diffinery instance, and whenever you start it by hand. On GitHub it doesn't run on pushes; start it by hand there (`workflow_dispatch`). | |
| 71 | +The Deploy job runs on every push to `main` when your copy lives on a Diffinery instance, and whenever you start it by hand. On GitHub it runs on pushes to `main` only when the repository variable `DEPLOY_ON_PUSH` is `true` (Settings > Secrets and variables > Actions > Variables), after the CI workflow passes on that commit. Without it, start the workflow by hand there (`workflow_dispatch`). Leave `DEPLOY_ON_PUSH` unset on a GitHub mirror of a repository that already deploys from Diffinery, or both would deploy. | |
| 72 | 72 | |
| 73 | 73 | The workflow doesn't pass `BOOTSTRAP_ADMINS`. Set the list with a first deploy from your machine (`scripts/setup.sh`), or put it under `vars` in your copy's `wrangler.jsonc`; after that, workflow deploys keep it. |
| 74 | 74 |