> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# CI/CD Integration

> Use ubx in GitHub Actions, GitLab CI, and other CI/CD pipelines.

ubx works well in CI/CD pipelines. This guide covers common patterns for GitHub Actions and GitLab CI.

## GitHub Actions

### Plan on Pull Request

```yaml theme={null}
name: ubx plan

on:
  pull_request:
    paths:
      - '**.iac'
      - 'ubx.yaml'

jobs:
  plan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.21'

      - name: Install ubx
        run: go install github.com/ubiquex/ubx@latest

      - name: Install Pulumi
        uses: pulumi/actions@v5

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: eu-west-1

      - name: ubx validate
        run: ubx validate --compile

      - name: ubx plan
        run: ubx plan --env staging
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
          UBX_AI_API_KEY: ${{ secrets.UBX_AI_API_KEY }}
```

### Apply on Merge to Main

```yaml theme={null}
name: ubx apply

on:
  push:
    branches: [main]
    paths:
      - '**.iac'
      - 'ubx.yaml'

jobs:
  apply:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install ubx
        run: go install github.com/ubiquex/ubx@latest
      - name: Apply
        run: ubx apply --yes --env prod
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
```

## CI Flags

| Command       | CI-safe variant                  |
| ------------- | -------------------------------- |
| `ubx apply`   | `ubx apply --yes`                |
| `ubx destroy` | `ubx destroy --force`            |
| `ubx upgrade` | `ubx upgrade --check`            |
| `ubx review`  | `ubx review --min-severity high` |
| `ubx fmt`     | `ubx fmt --check`                |

## Non-Interactive Detection

ubx automatically detects non-interactive environments (piped stdin, CI env vars) and skips confirmation prompts. `--yes` is an explicit override.

## Version Constraints

Pin the minimum ubx version in `ubx.yaml` to prevent CI surprises:

```yaml theme={null}
ubx_version: ">= 1.0.0"
```
