---
agent:
  instructions: "Use this search API to find Volcano documentation, blog posts, and cookbook recipes with keywords or a natural-language question, instead of crawling individual pages. Results are markdown: the best-matching pages with the sections that matched, and a link to each page's full markdown."
  endpoint: "https://docs.staging.volcano.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.staging.volcano.dev/docs/cli/docs-search#search-from-an-agent-over-http"
---

# Import a GitHub repository

Create a new Volcano project from an existing GitHub repository: check what it deploys, then connect it and queue its first deployment.

Import creates a new project from a GitHub repository you already reach through
the Volcano GitHub App. It connects the repository and branch, turns on
auto-deploy, and queues the first deployment of the branch head, so later
pushes deploy as described in [Deploy from GitHub](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md).

```bash
curl -X POST "https://api.volcano.dev/imports/github/runs" \
  -H "Authorization: Bearer $VOLCANO_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: import-storefront-1" \
  -d '{
    "connection_id": "9f1c2b7e-1f34-4a0d-9c7a-5b2f1d0e8a11",
    "source_id": "812345678",
    "project_name": "storefront",
    "target": "production",
    "branch": "main",
    "preflight_fingerprint": "sha256:5d1e…",
    "variables": [
      { "name": "STRIPE_SECRET_KEY", "value": "sk_live_…" }
    ]
  }'
```

An import takes three calls: list the repositories you can import, run a
preflight that reports what the branch head deploys, then start the import with
the preflight's fingerprint.

## Before you start

Connect GitHub and install the Volcano GitHub App on the account that owns the
repository, as in [Connect GitHub](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#1-connect-github). Read your
connection's `id` from `GET /user/git/connections`; every import call takes it
as `connection_id`. Volcano reaches the repository only through your own
connection and the App's installations it can see.

## List repositories

```bash
curl "https://api.volcano.dev/imports/github/sources?connection_id=$CONNECTION_ID" \
  -H "Authorization: Bearer $VOLCANO_TOKEN"
```

```json
{
  "sources": [
    {
      "id": "812345678",
      "name": "acme/storefront",
      "account_id": "acme",
      "framework": "",
      "repository": {
        "installation_id": 52001234,
        "account_login": "acme",
        "full_name": "acme/storefront",
        "default_branch": "main",
        "private": true,
        "empty": false
      }
    }
  ]
}
```

The list holds every repository of every installation your connection reaches.
`id` is the repository's numeric GitHub ID; send it as `source_id`. A
repository with `empty: true` has no commits and can't be imported.

## Check what the import deploys

Preflight changes nothing. It pins the branch to its head commit, prepares that
commit the way a deployment does, and reports what it found in `source_scan`:

```bash
curl -X POST "https://api.volcano.dev/imports/github/preflight" \
  -H "Authorization: Bearer $VOLCANO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "9f1c2b7e-1f34-4a0d-9c7a-5b2f1d0e8a11",
    "source_id": "812345678",
    "project_name": "storefront",
    "target": "production",
    "branch": "main",
    "root_directory": ""
  }'
```

| Field | Required | Description |
| --- | --- | --- |
| `connection_id` | yes | Your GitHub connection's `id`. |
| `source_id` | yes | The repository's `id` from the list. |
| `project_name` | yes | The new project's name: letters, digits, `_` and `-`. |
| `target` | yes | `production`. |
| `branch` | no | The branch to deploy. It becomes the project's production branch. Defaults to the repository's default branch. |
| `root_directory` | no | The directory holding the project, as in a monorepo. Empty or omitted means the repository root. It becomes the project's root directory. |

The response is an import report. The parts that matter for a GitHub
repository:

```json
{
  "provider": "github",
  "readiness": "importable",
  "fingerprint": "sha256:5d1e…",
  "source_scan": {
    "repository_id": 812345678,
    "repository_full_name": "acme/storefront",
    "installation_id": 52001234,
    "branch": "main",
    "commit_sha": "6f2b1c9a4e8d3f7b0a5c2e9d1f4b8a6c3e7d0b25",
    "root_directory": "",
    "functions": [
      { "name": "checkout", "runtime": "nodejs22.x", "kind": "standard" }
    ],
    "frontends": [
      { "name": "storefront", "workspace": "", "app_root": "", "framework": "nextjs", "supported": true }
    ],
    "migrations": [
      { "database": "", "files": ["001_create_orders.sql"] }
    ],
    "sandboxes": [],
    "unsupported": [],
    "deployable": true
  },
  "findings": [
    {
      "code": "github.migrations_after_first_deploy",
      "resource": { "kind": "git_repository", "name": "acme/storefront" },
      "disposition": "deferred",
      "impact": "warning",
      "message": "The first deployment does not apply the 1 SQL files under volcano/migrations: a new project has no database yet.",
      "remediation": "Add the project's database, then push to main with deploy_migrations on to apply them, or baseline them if the database already has this schema."
    }
  ]
}
```

### What preflight finds

- **Functions** come only from `volcano/functions`, with the same
  [layout rules](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#repository-layout) as a push. A `functions/`
  directory at the root directory is listed as unsupported, never deployed.
  So is a function directory holding TypeScript but no entry the build
  compiles.
- **Frontends:** without `.volcano/source-layout.json`, the app at the root
  directory is the one frontend, named after the project (or `web` when the
  project name isn't a valid frontend name). With a source layout, every
  frontend it names is listed. A frontend has `supported: false` only when
  Volcano can tell the [frontend build](https://docs.staging.volcano.dev/docs/platform/frontends/deploy.md) would refuse
  it: there is no app at its path; nothing marks it as a Next.js app (no `next`
  dependency, `next build` script, `next.config.*` file, or `app/` or `pages/`
  directory, at the top or under `src/`); no package declares `next` for the build to install; it holds
  more than one Next.js app and no app root picks one; or its Next.js version
  is one the build refuses. Any other frontend has `supported: true`, and the
  build decides. A `package.json` that names no framework beside functions is
  their dependency manifest and isn't listed.
- **Migrations** under `volcano/migrations` are listed per database. The import
  never applies them; see [Migrations](#migrations).
- **Unsupported items** are listed in `unsupported`, each with its path and
  reason, and as findings. The import leaves them out and deploys everything
  else, except a function holding TypeScript with no entry the build
  compiles, which blocks the import.

`deployable` is `true` when the commit holds at least one function or one
supported frontend. When it is `false`, `readiness` is `blocked` by the finding
`import.nothing_deployable`, whose message names what was found.

An unsupported frontend is left out of the import's first deployment. Its
`github.unsupported_frontend` finding is a warning; everything else deploys.
An unsupported frontend at the root directory isn't selected, so later pushes
don't deploy it until you make it an app Volcano can build and select it in the
project's [Git deploy settings](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#4-turn-on-auto-deploy). One that
`.volcano/source-layout.json` names is left out of later pushes until Volcano
can build it, as described in [Exported projects with multiple
frontends](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#exported-projects-with-multiple-frontends). Once it has
deployed, a later commit that makes it unbuildable fails that push with
`source_invalid`.

Two findings block the import, so `readiness` is `blocked` and the import
can't start: `github.unsupported_function` for a function holding TypeScript
with no entry the build compiles, since that would fail the first deployment,
and `import.nothing_deployable`. Add an entry such as `index.ts` or remove the
function, then run preflight again.

| Finding | Impact | Meaning |
| --- | --- | --- |
| `github.unsupported_frontend` | `warning` | A frontend that isn't deployed. |
| `github.unsupported_function` | `warning`, or `blocking` for TypeScript with no entry the build compiles | A function that isn't deployed. |
| `github.migrations_after_first_deploy` | `warning` | Migration files the first deployment doesn't apply. |
| `import.nothing_deployable` | `blocking` | No function and no supported frontend. |

### Preflight errors

| Status | `code` | Cause |
| --- | --- | --- |
| `422` | `import_repository_empty` | The repository has no commits. |
| `422` | `import_branch_not_found` | The branch doesn't exist. |
| `422` | `import_source_invalid` | A deployment would refuse the commit, such as a missing `root_directory` or an invalid `volcano-config.yaml`. `error` gives the reason. |
| `403` | | The App installation no longer has access to the repository. |
| `404` | | Your connection can't reach the repository through any installation, or the connection isn't yours. |
| `409` | | The GitHub connection must be reconnected. |
| `429` | | GitHub's rate limit, or another preflight or start of yours is still preparing a repository. Retry shortly. |

## Start the import

Send the preflight fields again with the report's `fingerprint` and an
`Idempotency-Key` header:

```bash
curl -X POST "https://api.volcano.dev/imports/github/runs" \
  -H "Authorization: Bearer $VOLCANO_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: import-storefront-1" \
  -d '{
    "connection_id": "9f1c2b7e-1f34-4a0d-9c7a-5b2f1d0e8a11",
    "source_id": "812345678",
    "project_name": "storefront",
    "target": "production",
    "branch": "main",
    "preflight_fingerprint": "sha256:5d1e…",
    "variables": [
      { "name": "STRIPE_SECRET_KEY", "value": "sk_live_…" }
    ]
  }'
```

```json
{
  "id": "0b8e6f2a-3c4d-4e5f-8a9b-1c2d3e4f5a6b",
  "provider": "github",
  "source_id": "812345678",
  "destination_project_name": "storefront",
  "resource": { "type": "project", "id": "4f7d2c1a-9b8e-4d6f-a5c3-2e1b0d9f8a7c", "name": "storefront" },
  "deployment": { "id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d" },
  "status": "pending",
  "created_at": "2026-12-01T10:15:00Z",
  "updated_at": "2026-12-01T10:15:00Z"
}
```

| Field | Description |
| --- | --- |
| `preflight_fingerprint` | The `fingerprint` of the report you showed the user. |
| `variables` | Project variables to store before the first deployment, up to 500. Volcano reads nothing from the repository's env files. |
| `deploy_migrations` | Sets the project's `apply_migrations` Git deploy setting, so later pushes apply the commit's migrations; the first deployment never does. Defaults to `false`. It lets anyone who can push to the branch run SQL as the database owner, so protect the branch first, as in [Apply migrations on push](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#apply-migrations-on-push). |

The import creates the project and connects it to the repository with:

- the selected branch as the production branch, and the selected root directory;
- auto-deploy and function deploys on;
- the root-directory frontend selected when preflight reported it supported.

The project keeps accepting direct deploys from the CLI and API, as any
connected project does; see
[Deploying directly while connected](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#deploying-directly-while-connected).

Retrying with the same `Idempotency-Key` and body returns the same run. The same
key with a different body answers `409`. A push to the branch after preflight
changes its head, so the start answers `409` as stale: run preflight again and
show the user the new report.

### Start errors

| Status | `code` | Cause |
| --- | --- | --- |
| `400` | `import_variable_name_invalid` | A `variables` name isn't a valid variable name. `error` quotes it. Nothing is created. |
| `400` | `feature_unavailable` | `deploy_migrations` is `true` while database migrations are unavailable. |
| `409` | | The preflight is stale, the idempotency key was reused with another body, or the project name is taken. |
| `413` | | The request body is larger than 1 MiB. |
| `422` | `import_source_not_importable` | Preflight's `readiness` is `blocked`: nothing in the commit can be deployed, or a function holds TypeScript with no entry the build compiles. `error` gives the blocking finding's message. |
| `422` | `import_repository_empty`, `import_branch_not_found`, `import_source_invalid` | As for preflight; so are `403`, `404` and `429`. |

## Follow the first deployment

Poll the run, or follow the deployment as a
[deployment run](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#check-deployment-runs):

```bash
curl "https://api.volcano.dev/imports/github/runs/$RUN_ID" \
  -H "Authorization: Bearer $VOLCANO_TOKEN"
```

`status` moves from `pending` through `running` to `succeeded` or `failed`.
A failed run has `error_code`: `import.deployment_skipped`, or the Git
deployment run's own code, such as `source_invalid` or `deploy_failed`. Treat
a code you don't know as a failure.

## Migrations

The first deployment never applies migrations, even with `deploy_migrations`
on: a new project has no database yet. Preflight lists the files it found and
reports `github.migrations_after_first_deploy`. Create the project's database,
then apply them by pushing with migrations on, as described in
[Apply migrations on push](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md#apply-migrations-on-push).

## Related

- [Deploy from GitHub](https://docs.staging.volcano.dev/docs/platform/projects/git-deploy.md) — what each push deploys after the import
- [Export your source to GitHub](https://docs.staging.volcano.dev/docs/platform/projects/export-to-git.md) — the opposite direction,
  from a Volcano project to a new repository
- [Environment variables](https://docs.staging.volcano.dev/docs/platform/functions/environment-variables.md) — managing the
  variables you set at import
