Skip to main content

GitHub Actions

Run Station AI agents directly in your GitHub workflows without installing Station locally. The station-action supports three modes for loading agents.

Quick Start

The easiest way to add a Station agent workflow to your repository is using the CLI:
stn github init
This interactive command will:
  1. Ask how you want to provide agents (CloudShip bundle ID or local environment)
  2. Help you select an agent to run
  3. Configure the workflow trigger (push, PR, schedule, manual)
  4. Generate .github/workflows/station-agent.yml
  5. Tell you which GitHub secrets to configure
Example session:
$ stn github init

🚀 Station GitHub Actions Setup
================================

How would you like to provide agents?
  1. CloudShip Bundle ID (recommended - keeps repo clean)
  2. Local environment (agents stored in repo)

Choice [1]: 1
Enter your CloudShip Bundle ID: 970fa728-4276-4443-9e51-35919b650d7a
Enter agent name to run: posthog-dashboard-reporter

When should this workflow run?
  1. On push to main branch
  2. On pull requests
  3. On a schedule (e.g., daily)
  4. Manual trigger only

Choice [4]: 4

✅ GitHub Actions workflow created!

📄 File: .github/workflows/station-agent.yml

🔐 Required GitHub Secrets:
   OPENAI_API_KEY      - Your OpenAI API key
   CLOUDSHIP_API_KEY   - Your CloudShip API key

Set secrets at: https://github.com/<owner>/<repo>/settings/secrets/actions

Manual Setup

Alternatively, you can manually create the workflow. The simplest approach is using a CloudShip bundle ID:
name: Run AI Agent

on: [push]

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

      - uses: cloudshipai/station-action@main
        with:
          agent: 'posthog-dashboard-reporter'
          task: 'List all my dashboards and summarize my analytics setup.'
          bundle-id: '970fa728-4276-4443-9e51-35919b650d7a'
          cloudship-api-key: ${{ secrets.CLOUDSHIP_API_KEY }}
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}

Agent Source Modes

Station action supports three ways to load agents:

Action Inputs

InputDescriptionRequiredDefault
agentAgent name to runYes-
taskTask description for the agentYes-
bundle-idCloudShip bundle IDNo*-
bundle-urlURL to download bundle fromNo*-
environmentLocal environment nameNo*default
cloudship-api-keyCloudShip API key (for bundle-id mode)No-
providerAI provider (openai, anthropic, gemini, ollama)Noopenai
modelModel overrideNoProvider default
base-urlCustom API endpointNo-
timeoutExecution timeout in secondsNo300
max-stepsMaximum agent stepsNo50
*At least one of bundle-id, bundle-url, or environment must be specified. If none are provided, the action looks for a local environments/default folder.

AI Provider Configuration

- uses: cloudshipai/station-action@main
  with:
    agent: 'my-agent'
    task: 'Analyze the codebase'
    bundle-id: 'your-bundle-id'
    cloudship-api-key: ${{ secrets.CLOUDSHIP_API_KEY }}
    provider: 'openai'
    model: 'gpt-4o'
  env:
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Complete Examples

Analytics Reporter

Run a PostHog analytics agent to summarize your dashboards:
name: Weekly Analytics Report

on:
  schedule:
    - cron: '0 9 * * 1'  # Monday 9 AM
  workflow_dispatch:

jobs:
  report:
    runs-on: ubuntu-latest
    steps:
      - uses: cloudshipai/station-action@main
        with:
          agent: 'posthog-dashboard-reporter'
          task: |
            Generate a weekly analytics report:
            1. List all dashboards
            2. Summarize key metrics from each
            3. Highlight any significant changes
          bundle-id: '970fa728-4276-4443-9e51-35919b650d7a'
          cloudship-api-key: ${{ secrets.CLOUDSHIP_API_KEY }}
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}

PR Code Review

Review pull requests automatically:
name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: cloudshipai/station-action@main
        with:
          agent: 'code-reviewer'
          task: |
            Review the changes in this PR. Focus on:
            - Security vulnerabilities
            - Performance issues
            - Code quality and best practices
            - Potential bugs
          bundle-id: 'your-code-review-bundle-id'
          cloudship-api-key: ${{ secrets.CLOUDSHIP_API_KEY }}
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Security Scan on Push

Scan for security issues on every push:
name: Security Scan

on:
  push:
    branches: [main]

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

      - uses: cloudshipai/station-action@main
        with:
          agent: 'security-scanner'
          task: 'Scan the codebase for security vulnerabilities, exposed secrets, and dependency issues'
          bundle-id: 'your-security-bundle-id'
          cloudship-api-key: ${{ secrets.CLOUDSHIP_API_KEY }}
          timeout: '600'
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Publishing Bundles to CloudShip

To use bundle-id mode, first publish your agents to CloudShip:
# 1. Create agents in your local Station workspace
stn init
stn agent add --name "my-agent" --description "Does something useful"

# 2. Add MCP tools
stn mcp add --name "my-tools" --url "https://api.example.com/mcp"

# 3. Test locally
stn run "my-agent" --task "Test the agent"

# 4. Share to CloudShip
stn bundle share default

# Output shows your bundle ID:
# Bundle ID: abc123-def456-...
Store your bundle ID somewhere safe. You’ll need it for the bundle-id input in your workflows.

Build-Time Actions

Station also provides reusable actions for building bundles and Docker images.

Build Bundle

Create distributable bundles from environments:
- uses: cloudshipai/station/.github/actions/build-bundle@main
  id: bundle
  with:
    environment: 'production'
    version: '1.0.0'

- run: echo "Bundle created at ${{ steps.bundle.outputs.bundle-path }}"

Build Docker Image

Build and push Docker images:
- uses: cloudshipai/station/.github/actions/build-image@main
  with:
    source-type: 'environment'
    environment: 'production'
    image-name: 'my-org/station-production'
    image-tag: 'latest'
    push: 'true'
    registry-username: ${{ github.actor }}
    registry-password: ${{ secrets.GITHUB_TOKEN }}

Setup Station CLI

Install Station CLI without running an agent:
- uses: cloudshipai/station/.github/actions/setup-station@main
  with:
    version: 'latest'
  env:
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

- run: stn --version

Best Practices

Bundle-id mode keeps your repository clean - no Station configuration files to maintain. Agents are versioned separately in CloudShip.
Never hardcode API keys. Use GitHub secrets:
env:
  OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  CLOUDSHIP_API_KEY: ${{ secrets.CLOUDSHIP_API_KEY }}
Complex tasks may need longer timeouts:
with:
  timeout: '600'  # 10 minutes
Add manual trigger for easy testing:
on:
  workflow_dispatch:
  push:
    branches: [main]

Troubleshooting

Ensure the agent name matches exactly (case-sensitive). List available agents:
stn agent list
For bundle-id mode, verify:
  • cloudship-api-key is set correctly
  • Bundle ID is valid and not deleted
  • Your CloudShip account has access to the bundle
Ensure required environment variables are passed:
env:
  POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
  DATABASE_URL: ${{ secrets.DATABASE_URL }}

Next Steps