Skip to content

CI/CD Guide

Automate preference management with CI/CD integration.

Run macprefs without interactive prompts:

Terminal window
macprefs apply --config my-prefs.json --yes

The --yes flag skips the interactive confirmation prompt, enabling unattended execution.

Get machine-readable output for parsing in scripts:

Terminal window
macprefs plan --config my-prefs.json --format json

macprefs uses standard exit codes for scripting:

CodeMeaning
0Success / No drift / Valid
1Error / Gated feature / Invalid
2Drift detected (changes pending) / Non-critical issues

Examples:

  • plan returns 0 if config matches current state, 2 if changes are needed
  • apply returns 0 on success, 1 on error
  • preflight returns 0 (PASS), 2 (ISSUES FOUND), or 1 (FAIL)
name: Apply Preferences
on:
workflow_dispatch:
jobs:
apply:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install macprefs
run: brew install macprefs
- name: Run preflight
run: macprefs preflight
- name: Apply preferences
run: macprefs apply --config ./config.json --yes
env:
MACPREFS_LICENSE: ${{ secrets.MACPREFS_LICENSE }}

Add config validation to your PR checks:

name: Validate Config
on:
pull_request:
paths:
- '**.json'
jobs:
validate:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install macprefs
run: brew install macprefs
- name: Validate config files
run: |
for f in configs/*.json; do
echo "Validating $f..."
macprefs validate --config "$f"
done
VariableDescription
MACPREFS_LICENSELicense key for Pro features
MACPREFS_CONFIGDefault config file path (optional)
  1. Always run preflight first - Ensure the target system is ready
  2. Use --rollback-on-fail - Enabled by default, reverts on errors
  3. Validate configs in CI - Catch schema errors before deployment
  4. Store configs in version control - Track changes over time
  5. Use exit codes for logic - Branch on 0, 1, or 2 as needed