GitHub Integration

Connect repositories for PR preview comments and streamlined CI/CD.

Overview: ZeroDeploy's GitHub App posts deployment status comments directly on your pull requests, showing live preview URLs as deployments progress.

Features

How It Works

  1. Install the GitHub App on your GitHub account or organization
  2. Connect a site to a repository in the dashboard
  3. Set up CI/CD with GitHub Actions (workflow file generated for you)
  4. Push code — deployments automatically post comments on PRs

Setup Guide

Step 1: Install the GitHub App

Go to your site settings in the dashboard and click “Connect to GitHub”. You’ll be redirected to GitHub to install the ZeroDeploy app.

Choose which repositories to grant access to:

Step 2: Connect Your Site

After installing the app, you’ll see your GitHub installations in the dashboard. Select the repository you want to connect to your site.

For monorepos, you can also configure:

Step 3: Generate Workflow File

Click “Generate Workflow” to get a GitHub Actions workflow file customized for your site. Copy this file to your repository:

# .github/workflows/zerodeploy.yml
name: Deploy to ZeroDeploy

on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci && npm run build
      - name: Deploy to ZeroDeploy
        run: npx @zerodeploy/cli deploy --dir dist
        env:
          ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}

Step 4: Add Deploy Token Secret

Create a deploy token and add it as a repository secret:

  1. Create a token: zerodeploy token create "GitHub Actions" --site <site-id>
  2. In GitHub, go to Settings → Secrets → Actions → New repository secret
  3. Name: ZERODEPLOY_TOKEN
  4. Value: Paste your deploy token
Token Security: Deploy tokens are scoped to a single site and can only deploy. They cannot access other sites, delete deployments, or perform any other actions.

Customizing the Workflow

The generated workflow is a starting point. Here’s how to customize it for your project:

Build Configuration

The workflow has three main steps: InstallBuildDeploy. Customize each for your project:

steps:
  - uses: actions/checkout@v4

  # 1. Setup - choose your package manager
  - uses: actions/setup-node@v4
    with:
      node-version: '20'
      cache: 'npm'  # or 'yarn', 'pnpm'

  # 2. Install dependencies
  - run: npm ci  # or: yarn install --frozen-lockfile, pnpm install

  # 3. Build your app
  - run: npm run build

  # 4. Deploy the build output
  - run: npx @zerodeploy/cli deploy --dir dist
    env:
      ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}

The —dir Flag

The --dir flag must point to your build output directory, not your source code:

FrameworkBuild CommandOutput Directory
Vitenpm run builddist
Next.js (static)next buildout
Create React Appnpm run buildbuild
Vue CLInpm run builddist
Angularng builddist/<project-name>
Astronpm run builddist
SvelteKit (static)npm run buildbuild
Tip: If you're unsure of your output directory, run your build command locally and check which folder contains your index.html file.

Using Different Package Managers

pnpm:

- uses: pnpm/action-setup@v2
  with:
    version: 8
- uses: actions/setup-node@v4
  with:
    node-version: '20'
    cache: 'pnpm'
- run: pnpm install
- run: pnpm run build

Bun:

- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build

Environment Variables

If your build requires environment variables, add them to the build step:

- run: npm run build
  env:
    VITE_API_URL: https://api.example.com
    VITE_PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }}

Monorepo Working Directory

For monorepos, run commands in the correct directory:

# Install at root (for shared dependencies)
- run: npm ci

# Build in the app directory
- run: npm run build
  working-directory: apps/web

# Deploy the built output
- run: npx @zerodeploy/cli deploy web --dir apps/web/dist
  env:
    ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}

Preview vs Production Deploys

The CLI automatically detects PR deployments and creates previews instead of updating production. You can override this behavior:

# Force preview mode (even on main branch)
- run: npx @zerodeploy/cli deploy --dir dist --preview

# Force production deploy (even on PRs)
- run: npx @zerodeploy/cli deploy --dir dist --prod

PR Preview Comments

When you open a pull request or push commits, ZeroDeploy posts a comment showing deployment status:

## ZeroDeploy Preview

| Site | Status | Preview |
|------|--------|---------|
| **my-site** | ✅ Ready | [Open Preview](https://abc123-my-site.zerodeploy.app) |

---
**Commit:** `a1b2c3d`
**Updated:** 2024-01-15T10:30:00Z

Status updates in real-time:

StatusMeaning
🚀 Deploying…Deployment started
📤 Uploading…Files being uploaded
⚙️ Processing…Extracting and processing files
✅ ReadyDeployment complete, preview URL available
❌ FailedDeployment failed (check logs)

Monorepo Setup

For monorepos with multiple sites, each site gets its own workflow file with path filters:

# .github/workflows/zerodeploy-web.yml
name: Deploy web to ZeroDeploy

on:
  push:
    branches: [main]
    paths:
      - 'apps/web/**'
      - 'packages/**'
      - 'package.json'
  pull_request:
    types: [opened, synchronize, reopened]
    paths:
      - 'apps/web/**'
      - 'packages/**'
      - 'package.json'

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run build
        working-directory: apps/web
      - name: Deploy to ZeroDeploy
        run: npx @zerodeploy/cli deploy web --dir apps/web/dist
        env:
          ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}

Org-Scoped Tokens for Monorepos

Instead of creating a separate token for each site, create one org-scoped token that can deploy to any site in your organization:

# Create an org-scoped deploy token
zerodeploy token create "GitHub Actions" --org my-org

This single token works for all sites in the org, simplifying CI/CD setup for monorepos.

Consolidated PR Comments

When multiple sites deploy from the same PR, ZeroDeploy consolidates them into one comment:

## ZeroDeploy Previews

| Site | Status | Preview |
|------|--------|---------|
| **web** | ✅ Ready | [Open Preview](https://abc123-web.zerodeploy.app) |
| **dashboard** | ⚙️ Processing... | — |
| **admin** | 🚀 Deploying... | — |

---
**Commit:** `a1b2c3d`
**Updated:** 2024-01-15T10:30:00Z

Automatic CI Detection

The ZeroDeploy CLI automatically detects CI environments and extracts git metadata:

CI ProviderAuto-Detected
GitHub ActionsFull support
GitLab CIFull support
CircleCIFull support
Bitbucket PipelinesFull support
Azure PipelinesFull support
Travis CIFull support
JenkinsBasic support

The CLI extracts:

You can override auto-detected values with CLI flags:

zerodeploy deploy \
  --pr 123 \
  --commit abc123def456... \
  --branch feature/my-feature \
  --commit-message "My commit message"

PR Cleanup

When a PR is closed (merged or abandoned), ZeroDeploy automatically cleans up preview deployments after 30 days. This is handled by the retention system to free up storage.

GitHub App Permissions

The ZeroDeploy GitHub App requests minimal permissions:

PermissionAccessPurpose
ContentsReadView repository structure (for workflow generation)
Pull requestsWritePost and update PR comments
MetadataReadBasic repository information (required)

The app does not have access to:

Troubleshooting

PR comment not appearing

Workflow not triggering

Deployment failing in CI