Skip to main content

Overview

To use the Suga CLI in automated CI/CD environments, you need to authenticate without interactive login prompts. Personal Access Tokens provide a secure way to authenticate the CLI in:
  • GitHub Actions
  • GitLab CI
  • CircleCI
  • Jenkins
  • BitBucket Pipelines
  • Any CI/CD platform

Quick Start

Set the SUGA_ACCESS_TOKEN environment variable with your Personal Access Token:
export SUGA_ACCESS_TOKEN="your-token-here"
Once set, all Suga CLI commands will automatically authenticate using the token.

Prerequisites

Before setting up CI/CD authentication, you need to:
  1. Create a Personal Access Token
  2. Securely store the token in your CI/CD platform’s secrets management system
Never commit tokens directly to your repository. Always use your CI/CD platform’s encrypted secrets or environment variable features.

Platform-Specific Setup

  • GitHub Actions
  • GitLab CI
  • CircleCI
  • Jenkins

GitHub Actions

1

Add Token to Repository Secrets

  1. Navigate to your GitHub repository
  2. Go to Settings > Secrets and variables > Actions
  3. Click New repository secret
  4. Name: SUGA_ACCESS_TOKEN
  5. Value: Your Personal Access Token
  6. Click Add secret
2

Use in Workflow

name: Deploy with Suga

on:
  push:
    branches: [main]

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

      - name: Install Suga CLI
        run: |
          curl -sSL https://addsuga.com/install | sh
          echo "$HOME/.suga/bin" >> $GITHUB_PATH

      - name: Build and Deploy
        env:
          SUGA_ACCESS_TOKEN: ${{ secrets.SUGA_ACCESS_TOKEN }}
        run: |
          suga build
          # Additional deployment commands
Documentation: GitHub Actions Secrets

Using Tokens with Docker

When running Suga CLI in Docker containers, pass the token as an environment variable:
FROM ubuntu:22.04

# Install Suga CLI
RUN curl -sSL https://addsuga.com/install | sh

# Add Suga to PATH
ENV PATH="$HOME/.suga/bin:${PATH}"

# Token will be provided at runtime
ENV SUGA_ACCESS_TOKEN=""

WORKDIR /app
COPY . .

CMD ["suga", "build"]
Run the container:
docker run -e SUGA_ACCESS_TOKEN="your-token-here" your-image

Common CI/CD Workflows

Basic Build and Deploy

# Set token (typically done by CI platform)
export SUGA_ACCESS_TOKEN="your-token-here"

# Build infrastructure
suga build

# Deploy or additional commands
# ...

Conditional Deployment

# GitLab CI example
deploy:
  stage: deploy
  script:
    - suga build
  only:
    - main
    - tags
  except:
    - schedules

Using Tokens with Suga API

Personal Access Tokens can also be used directly with the Suga API as Bearer tokens:
curl -H "Authorization: Bearer your-token-here" \
     https://app.addsuga.com/api/teams/{your_team}/platforms
// Node.js example
const response = await fetch('https://app.addsuga.com/api/teams/{your_team}/platforms', {
  headers: {
    'Authorization': `Bearer ${process.env.SUGA_ACCESS_TOKEN}`
  }
});
# Python example
import os
import requests

headers = {
    'Authorization': f'Bearer {os.environ["SUGA_ACCESS_TOKEN"]}'
}

response = requests.get('https://app.addsuga.com/api/teams/{your_team}/platforms', headers=headers)

Next Steps