CI pipelines
One pipeline shape for every project that deploys to Pushleft (decided 2026-11-27). A push gets fast feedback. A preview shows the change first and tests it next to that. Production runs only a build whose tests passed. The full suites run every night.
The shape
| Job | When | Needs | Runs |
|---|---|---|---|
test:<lane> | every push | nothing | the fast tests of one lane: test:backend, test:frontend, test:mobile, test:rust, test:dotnet |
deploy:preview | a push to a preview branch | nothing (needs: []) | pl up |
build:production | a push to the default branch | nothing (needs: []) | pl up --production --hold |
deploy:production | a push to the default branch | build:production and every test:* job | pl release --production --commit <sha> |
deploy:site | a push to the default branch that changes the site | nothing | the static site (Cloudflare Pages) |
- Previews deploy first.
deploy:previewdoes not wait for the tests. The tests run next to it, and a red test shows on the same pipeline. - Production releases after the tests.
build:productionbuilds while the tests run.deploy:productionmakes that same commit live when they pass (release after tests). A failed test leaves the build held; it expires after 24 hours. - Full suites run nightly. A push runs only fast tests. The full suite, end-to-end tests and slow lanes run in the project’s
testsschedule at night (test runs). A push never starts that schedule: a long run would skip the nightly one. - Names. GitLab job names use a colon (
deploy:production). GitHub job IDs cannot, so they use a dash (deploy-production) withname: deploy:production. - The newest push wins. A newer
build:productioncancels an older held build, so cancel the older pipeline too: on GitLab,interruptible: trueon every job and “Auto-cancel redundant pipelines” on; on GitHub, a workflow-levelconcurrencywithcancel-in-progress: true(example below). - One production deploy at a time. GitLab:
resource_group: pushleft-productionondeploy:production. GitHub:concurrency: { group: pushleft-production }. - Tokens. Production jobs use
PUSHLEFT_TOKEN, an admin service token of the project’s organization. Keep it where only the default branch can read it: a protected variable on GitLab, an environment secret on GitHub. Preview jobs usePUSHLEFT_PREVIEW_TOKEN, a member service token, so a change to a branch’s CI file cannot reach the admin token. Do not add--org: a token names its organization. - Branch. CI often checks out a detached commit. Set
PL_GIT_BRANCHto the branch name, or every branch deploys topreview/local.
Installing pl in CI
Every repository keeps this script as ci/install-pl.sh (mode 0755). It installs the newest signed pl. It stops before the install when the signature or the checksum is wrong:
#!/bin/sh
# Installs the newest signed pl into $PL_BIN (default ~/.local/bin).
set -eu
R=https://releases.pushleft.dev
KEY=ycJxDG57xxcAbQEHazM+5VANSLxjrj1ZerDOjnGixgs= # the release key, pinned
BIN=${PL_BIN:-$HOME/.local/bin}
V=${PL_VERSION:-$(curl -fsS "$R/cli/latest")} # set PL_VERSION to pin
T=$(mktemp -d); cd "$T"
curl -fsSO "$R/cli/$V/SHA256SUMS" -fsSO "$R/cli/$V/SHA256SUMS.sig" -fsSO "$R/cli/$V/pl-linux-amd64"
{ printf '302a300506032b6570032100' | xxd -r -p; echo "$KEY" | base64 -d; } > release.der
base64 -d < SHA256SUMS.sig > SHA256SUMS.bin
openssl pkeyutl -verify -pubin -keyform DER -inkey release.der -rawin -in SHA256SUMS -sigfile SHA256SUMS.bin
sha256sum -c --ignore-missing --strict SHA256SUMS
mkdir -p "$BIN" && install -m 0755 pl-linux-amd64 "$BIN/pl"
[ "$("$BIN/pl" --version)" = "pl $V" ]
By default the script installs the newest release, so every project runs the same pl. Only Pushleft publishes latest, and only signed releases. Set PL_VERSION to pin one version, for example while you look into a change.
Add $PL_BIN to PATH: on GitLab, export PATH="$HOME/.local/bin:$PATH" in before_script; on GitHub, echo "$HOME/.local/bin" >> "$GITHUB_PATH". The runner needs curl, openssl, xxd and git.
GitLab CI
stages: [test, deploy]
default:
interruptible: true # a newer push cancels this pipeline
.pl: &pl
image: debian:bookworm-slim
variables:
PL_GIT_BRANCH: $CI_COMMIT_REF_NAME # GitLab checks out a detached commit
before_script:
- apt-get update -qq && apt-get install -y -qq curl openssl xxd git >/dev/null
- ci/install-pl.sh && export PATH="$HOME/.local/bin:$PATH"
test:backend:
stage: test
script: bin/rails test
deploy:preview:
<<: *pl
stage: deploy
needs: []
rules: [{ if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH }]
script: PUSHLEFT_TOKEN="$PUSHLEFT_PREVIEW_TOKEN" pl up
build:production:
<<: *pl
stage: test
needs: []
rules: [{ if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH }]
script: pl up --production --hold
deploy:production:
<<: *pl
stage: deploy
needs: [build:production, test:backend]
resource_group: pushleft-production
rules: [{ if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH }]
script: pl release --production --commit "$CI_COMMIT_SHA"
GitHub Actions
Put PUSHLEFT_TOKEN in a production environment that only the default branch may use.
on:
push:
branches: ['**'] # branches only, not tags
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
PL_GIT_BRANCH: ${{ github.ref_name }}
jobs:
test-backend:
name: test:backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: bin/rails test
deploy-preview:
name: deploy:preview
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ci/install-pl.sh && echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- run: pl up
env: { PUSHLEFT_TOKEN: "${{ secrets.PUSHLEFT_PREVIEW_TOKEN }}" }
build-production:
name: build:production
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ci/install-pl.sh && echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- run: pl up --production --hold
env: { PUSHLEFT_TOKEN: "${{ secrets.PUSHLEFT_TOKEN }}" }
deploy-production:
name: deploy:production
needs: [build-production, test-backend]
concurrency: { group: pushleft-production }
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ci/install-pl.sh && echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- run: pl release --production --commit "$GITHUB_SHA"
env: { PUSHLEFT_TOKEN: "${{ secrets.PUSHLEFT_TOKEN }}" }