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"
Prerequisites
Before setting up CI/CD authentication, you need to:
- Create a Personal Access Token
- 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.
-  GitHub Actions 
-  GitLab CI 
-  CircleCI 
-  Jenkins 
GitHub Actions
Add Token to Repository Secrets
- Navigate to your GitHub repository
- Go to Settings > Secrets and variables > Actions
- Click New repository secret
- Name: SUGA_ACCESS_TOKEN
- Value: Your Personal Access Token
- Click Add secret
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
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"]
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