Use the CLI in CI
The CLI is built to run unattended. In CI you authenticate with a token, deploy without a browser, and rely on exit codes instead of parsing output.
1. Create a token
In the dashboard, go to Settings → Tokens and create a token for the project or team you want CI to act as. Copy the value; it is shown once.
2. Store it as a secret
Add the token to your CI provider’s secrets (for GitHub, Settings →
Secrets and variables → Actions) as YOFIX_TOKEN. Every command reads
this variable automatically, and a variable is safer than --token
because it never lands in a process list or log.
3. Deploy in the pipeline
name: Preview deployon: [push]
jobs: preview: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # full history so the branch label is correct
- uses: actions/setup-node@v4 with: node-version: 20
- run: npm install -g @yofix/cli
- name: Deploy preview env: YOFIX_TOKEN: ${{ secrets.YOFIX_TOKEN }} run: yofix deploy --no-wait --json > deploy.json
- name: Show the preview URL run: jq -r '.data.previewUrl' deploy.jsonDeploy to production from your default branch by gating on the ref and
adding --prod:
- name: Deploy production if: github.ref == 'refs/heads/main' env: YOFIX_TOKEN: ${{ secrets.YOFIX_TOKEN }} run: yofix deploy --prodWaiting versus not waiting
- Use
--no-waitwhen a later job (or the YoFix PR comment) reports the result, and you just want to enqueue the build. - Drop
--no-waitwhen the pipeline should fail if the build fails. A waiting deploy exits non-zero on a failed build, so the job turns red automatically.
yofix deploy --prod --timeout 900 # block up to 15 minutes, fail if the build failsBranching on the outcome
Exit codes are stable, so you can react to specific failures:
# CI shells run with `set -e`, so capture the status instead of letting a# non-zero `yofix deploy` abort the step before the `case` runs.status=0yofix deploy --prod || status=$?case $status in 0) echo "Deployed" ;; 10) echo "Build failed"; exit 1 ;; # YF_DEPLOY_BUILD_FAILED 7) echo "Quota reached"; exit 1 ;; # YF_QUOTA_EXCEEDED *) echo "Unexpected failure"; exit 1 ;;esacOr parse the JSON envelope when you need detail:
yofix ls --json | jq -r '.data[] | "\(.status)\t\(.previewUrl)"'See the full table in Global options and output.