deploy

Deploy a repository as a new app in one call: a public one on any git host, or one of your own repos.

noclick.deploy copies the repository (or takes your repo as it is), makes the app, sets the secrets it reads, gives it the key to your account it asks for (or has the deploy ask the account's owner), and deploys production. Ask with dry_run=True first to see what it would do, what it would cost a month and what it asks of you, with nothing made.

plan = noclick.deploy("https://github.com/acme/console", dry_run=True)
print(plan.runtime, f"${plan.estimate.monthly_usd:.2f} a month", plan.missing_secrets)

app = noclick.deploy("https://github.com/acme/console", secrets={"STRIPE_SECRET_KEY": "sk_live_..."}).wait()
print(app.url)
function deploy(
  source: string | ApiObject,
  options: DeployOptions & { dryRun: true },
): Promise<DeployPlan>
function deploy(
  source: string | ApiObject,
  options?: DeployOptions & { dryRun?: false },
): Promise<RepoDeploy>

Deploy source as a new app of yours: a public git repository's https URL, on any host (copied into a new repo of yours, the one branch it deploys), or one of your own repos (a Repo, its id or its name, deployed as it is).

It makes the app, sets the secrets its noclick.json says its code reads (NoClick makes the ones marked generate; secrets brings the rest), gives the app the key to your account it asks for when accountKey names exactly its scopes (only you signed in, or a key holding keys:create; otherwise the deploy asks the account's owner), and deploys production. Never a private repository, a URL with a login, an ssh:// or git@ address, or another account's repo: push a private one to a repo of yours with git and deploy that. What can't deploy is refused before anything is made. Needs the apps and repos scopes.

Resolves to a RepoDeploy whose wait() gives the live app (url, where its key stands, passwords to read once); with dryRun: true, to a DeployPlan of what it would do, what it would cost and what it asks of you.

const plan = await deploy("https://gitlab.com/acme/tools/console", { dryRun: true });
for (const line of plan.accountKey?.can ?? []) console.log("its key can", line.can);
const done = await (await deploy("https://gitlab.com/acme/tools/console", {
  secrets: { STRIPE_SECRET_KEY: "sk_live_..." },
})).wait();
const app = Project.fromId(done.projectId);
for (const name of done.toReveal) console.log(name, await app.secrets.reveal(name));
Parameters
sourcestring | ApiObjectrequired
options.dryRunbooleanrequired

Answer what it would do, with nothing made (only reading the repository is charged, its seconds).

options.refstring

A branch, tag or full commit sha to deploy (the repository's default branch when omitted).

options.namestring

The app's name (and its copy's); omitted, the repository's own, or the first of name-2, name-3... free.

options.secretsRecord<string, string>

Values for the secrets the repository's noclick.json asks you to set, by name. Write-only.

options.accountKeystring[]

Give the app the key to your account it asks for, as part of the deploy: exactly its scopes, as the dry run names them. Only you signed in, or a key holding keys:create; otherwise leave it out and the deploy asks the account's owner.

options.keySpendCapUsdPerMonthnumber

The most the key may spend in a calendar month (none of its own unless set).

options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

A RepoDeploy operation whose wait() gives a DeployResult (the app's url, where its key stands, the passwords to read once); with dry_run=True, a DeployPlan of what it would do, what it would cost a month and what it asks of you, with nothing made.

Types
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

DeployPlan

class DeployPlan

What a deploy would do, with nothing made: deploy(source, { dryRun: true }).

Attributes
sourceJsonObject

What it read: kind (url or repo), the url or repo_id, and the commit and branch.

namestring

The app's name (and its copy's): the one you gave, or the first free one from the repository's.

runtimestring | null

Where the app would run (edge or container); null when it won't run as it stands.

frameworkstring | null
reasonstring | null
noclickJsonboolean

Whether the repository has a noclick.json.

accountKeyDeployKeyAsk | null
secretsDeploySecret[]
missingSecretsstring[]

The secrets you set that the call would have to bring: a deploy without them is refused.

refusedJsonObject | null

Why it won't deploy as it stands (message, next_step); null when it will.

estimateEstimate

What it would cost a month, priced for your account (usage-based: what's charged is what's used).

fundsJsonObject

Whether your account can pay to run it now (ok); if not, the refusal a deploy would meet.

makesstring[]

What it makes: repo (a copy) and project (the app).

rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };

DeployResult

interface DeployResult

A deploy that ended live: what RepoDeploy.wait() resolves to.

Attributes
projectIdstring
namestring
urlstring | null

Where production serves it.

repoIdstring | null
deploymentIdstring | null
commitstring | null
accountKeyJsonObject | null

Where its key to the account stands (status: granted, waiting for the owner...); null if it asks none.

toRevealstring[]

The passwords NoClick made that nobody has read yet: read each once with app.secrets.reveal(name).

rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };

DeploySecret

interface DeploySecret

A secret the repository's noclick.json says its code reads.

Attributes
namestring
generatestring | null

What NoClick makes for it (secret or password); null for one you set.

descriptionstring | null

What it is, in the repository's words.

requiredboolean

For one you set: whether a deploy without it is refused. One NoClick makes is always there.

givenboolean

For one you set: whether the call brought its value.

shownOnceboolean

For one NoClick makes: whether it's a password you read once (app.secrets.reveal).

DeployKeyAsk

interface DeployKeyAsk

The key to your account the repository asks for, as you're shown it before you agree.

Attributes
scopesstring[]
canJsonObject[]

What the key can do, a line per scope (scope, can, reads_secrets).

cannotstring[]

What no app's key can do, whatever it holds.

notestring

That whoever can change the app's code acts with the key.

givenBy"you" | "deploy"

you: you give it in the call (send accountKey with these scopes); deploy: the deploy asks for it.

atDeploystring | null

When the deploy asks: asks_owner, given or denied, as the account's app_key approval setting decides.

Types
type JsonObject = { [key: string]: unknown };

RepoDeploy

class RepoDeploy extends Operation

A repository being deployed as a new app: the operation deploy returns. wait() resolves to a DeployResult once it's live; progress shows each stage (copying, making the app, setting its secrets and key, building and deploying). A deploy that fails after the copy keeps the app and its repo, and its error says how to go on.

Attributes
projectIdstring | null

The new app's id, once it's made.

repoIdstring | null

The repo it deploys: the copy, or yours.

deploymentIdstring | null

The production deployment, once it's started.