CI/CD Setup
UiGraph CLI is designed for non-interactive CI/CD runs.
Recommended flow
- Pull requests:
uigraph-cli sync --dry-run - Main branch:
uigraph-cli sync
GitHub Actions
name: UiGraph Sync with Dry Run on PR
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
uigraph-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Install UiGraph CLI
run: GOBIN=/usr/local/bin go install github.com/uigraph-app/uigraph-cli@latest
- name: UIGraph Sync (dry-run on PR)
if: github.event_name == 'pull_request'
env:
UIGRAPH_TOKEN: ${{ secrets.UIGRAPH_TOKEN }}
run: uigraph-cli sync --dry-run
- name: UIGraph Sync
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
UIGRAPH_TOKEN: ${{ secrets.UIGRAPH_TOKEN }}
run: uigraph-cli sync
Repository examples:
examples/ci-cd/github-actions.ymlexamples/ci-cd/github-actions-advanced.yml
GitLab CI
Use a job image that includes Go (for example the official golang image), then install the CLI with go install—same module as in GitHub Actions.
default:
image: golang:bookworm
before_script:
- GOBIN=/usr/local/bin go install github.com/uigraph-app/uigraph-cli@latest
uigraph-dry-run:
stage: test
script:
- uigraph-cli sync --dry-run
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
uigraph-sync:
stage: deploy
script:
- uigraph-cli sync
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "master"
Define UIGRAPH_TOKEN under Settings → CI/CD → Variables (masked, protected if needed). On older GitLab versions you can replace rules with only / except equivalents.
Repository example:
examples/ci-cd/gitlab-ci.yml
Best practices
- Store
UIGRAPH_TOKENin CI secret managers. - Keep
.uigraph.yamland referenced files in the same repo. - Run dry-run in every PR to catch config and path errors early.
- Prefer repository-pinned examples over copied snippets when onboarding teams.