CI/CD Setup
UiGraph CLI is designed for non-interactive CI/CD runs.
Recommended flow
- Pull requests:
uigraph sync --dry-run - Main branch:
uigraph sync
GitHub Actions
name: UiGraph Sync with Dry Run on PR
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
uigraph-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install UiGraph CLI
run: |
go install github.com/uigraph/uigraph-cli@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Dry run on PR
if: github.event_name == 'pull_request'
env:
UIGRAPH_TOKEN: ${{ secrets.UIGRAPH_TOKEN }}
run: uigraph sync --dry-run
- name: Sync on main
if: github.event_name == 'push'
env:
UIGRAPH_TOKEN: ${{ secrets.UIGRAPH_TOKEN }}
run: uigraph sync
Repository examples:
examples/ci-cd/github-actions.ymlexamples/ci-cd/github-actions-advanced.yml
GitLab CI
uigraph-dry-run:
stage: test
script:
- curl -sSL https://cli.uigraph.app/install.sh | sh
- uigraph sync --dry-run
only:
- merge_requests
variables:
UIGRAPH_TOKEN: $UIGRAPH_TOKEN
uigraph-sync:
stage: deploy
script:
- curl -sSL https://cli.uigraph.app/install.sh | sh
- uigraph sync
only:
- main
- master
variables:
UIGRAPH_TOKEN: $UIGRAPH_TOKEN
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.