Skip to content

Commit b2ffa4d

Browse files
kristof-siketclaude
andcommitted
Document the GitHub Actions push-to-deploy flow for Composer apps
The GitHub integration page described platform-side webhook builds ("push builds the pushed commit"), which is not how deploys work: deploys run in the repository's own GitHub Actions through prisma/cloud-deploy-action, while the connection contributes the OIDC credential exchange and the branch lifecycle automation (preview teardown on branch delete). - Add compute/deploy-on-push.mdx: a walkthrough from a locally deployed Composer app to push-to-deploy with per-branch preview stages, validated end to end against a real pipeline on 2026-08-25. - Rewrite compute/github.mdx around what the connection actually does, including the two entry paths (Console adds the workflow via PR, the CLI path does not) and the interactive-only git connect. - Align branching, deployments, index, cli/v8/git, composer/deploying, and the full-stack tutorial's next step with the real flow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7b8d85c commit b2ffa4d

9 files changed

Lines changed: 192 additions & 37 deletions

File tree

apps/docs/content/docs/(index)/full-stack-tutorial.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,4 @@ npx prisma@next project delete <project-id> --confirm <project-id>
259259
- [Pick your framework](/guides/v8): the same journey for Next.js, Nuxt, Astro, NestJS, TanStack Start, and more.
260260
- [Branching and previews](/compute/branching): every Git branch gets an isolated deployment.
261261
- [Learn the fundamentals](/orm/v8/fundamentals/reading-data): reading, writing, relations, and transactions.
262-
- [Deploy on push](/compute/github): connect GitHub so every commit deploys itself.
262+
- [Deploy on push](/compute/deploy-on-push): connect GitHub so every commit deploys itself, with a preview environment per branch.

apps/docs/content/docs/cli/v8/git.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ metaTitle: git | Prisma 8 CLI
66
metaDescription: Learn how to connect and disconnect a GitHub repository for Prisma Compute push-to-deploy with the unified Prisma CLI.
77
---
88

9-
Use `git` commands to manage the GitHub repository connection. See [GitHub integration](/compute/github).
9+
Use `git` commands to manage the GitHub repository connection. Connecting enables the OIDC credential exchange for GitHub Actions deploys and the branch lifecycle automation; the deploys themselves run in your repository's own workflow. See [GitHub integration](/compute/github) and [Deploy on push](/compute/deploy-on-push).
1010

1111
## Usage
1212

1313
```npm
1414
npx prisma@next git connect
1515
```
1616

17+
Run it from a [linked](/cli/v8/project) project directory. The command is interactive: it opens the browser to install the GitHub App when needed and waits for the install, so `--no-interactive` fails with `CLI.INTERACTION_REQUIRED`. Connecting from the CLI does not add a deploy workflow to the repository; [add it yourself](/compute/deploy-on-push#4-add-the-deploy-workflow), or connect through the [Console](https://pris.ly/pdp), which opens a pull request with the workflow.
18+
1719
## Commands
1820

1921
| Command | Description |
2022
| ------------------------ | ----------------------------------------------------------------- |
2123
| `git connect [git-url]` | Connect the linked project to a GitHub repository. Starts the GitHub App install flow if needed |
22-
| `git disconnect` | Stop push-triggered automation. Keeps the project and existing branches |
24+
| `git disconnect` | Stop the credential exchange and branch automation. Keeps the project and existing branches |

apps/docs/content/docs/composer/deploying.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ Destroying a stage removes its resources, then deletes its branch along with the
108108

109109
## CI
110110

111-
CI runs the same commands as your machine: set the two credential variables as CI secrets, build, and deploy. The per-PR environment pattern:
111+
On GitHub, the ready-made path is [Deploy on push](/compute/deploy-on-push): connect the repository and add [prisma/cloud-deploy-action](https://github.com/prisma/cloud-deploy-action) to your workflow. The action derives the target from the branch, so the default branch deploys production and every other branch deploys its own stage, and connected repositories authenticate through GitHub's OIDC tokens with no secrets at all.
112+
113+
Any other CI runs the same commands as your machine: set the two credential variables as CI secrets, build, and deploy. The per-PR environment pattern:
112114

113115
```bash
114116
npx prisma@next deploy module.ts --stage "pr-$PR_NUMBER" # on push

apps/docs/content/docs/compute/branching.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Listing branches doesn't expand the services and databases inside them. Use the
4747

4848
You rarely create branches manually. They are created automatically:
4949

50-
- **From GitHub**: when a repo is connected, branch and push events create or update the matching platform branch automatically. To set this up, see the [GitHub integration docs](/compute/github).
50+
- **From GitHub**: when a repo is connected, creating a Git branch creates the matching platform branch, and your repository's [deploy workflow](/compute/deploy-on-push) deploys each push to it as a preview. To set this up, see the [GitHub integration docs](/compute/github).
5151
- **From the CLI**: commands that target a branch that doesn't exist yet, such as `service create --branch feature/search` or a [Composer stage deploy](/composer/deploying), create it.
5252

5353
Connecting GitHub doesn't create branches retroactively. It aligns your default branch with the repo's default branch and wires up automation for future events.
@@ -59,4 +59,5 @@ When GitHub is connected, deleting a Git branch tears down the matching platform
5959
## Next steps
6060

6161
- [Environment variables](/compute/environment-variables): preview values and per-branch overrides.
62+
- [Deploy on push](/compute/deploy-on-push): a preview environment for every branch you push.
6263
- [GitHub integration](/compute/github): keep platform branches in sync with your repo.
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: Deploy on push
3+
description: Graduate a Composer app from manual deploys to a Git workflow, with production deploys on push and an isolated preview environment per branch.
4+
url: /compute/deploy-on-push
5+
metaTitle: Deploy on push | Prisma Compute
6+
metaDescription: Connect a GitHub repository and deploy a Prisma Composer app from GitHub Actions with prisma/cloud-deploy-action - production on the default branch, isolated preview stages per branch, automatic teardown.
7+
---
8+
9+
You have a [Composer](/composer) app that deploys from your terminal with `deploy module.ts`, the way the [full-stack tutorial](/full-stack-tutorial) left you. This guide graduates it to a Git workflow:
10+
11+
- A push to your default branch deploys **production**.
12+
- A push to any other branch deploys an isolated **preview stage**: its own services, its own databases, its own buckets, its own URL.
13+
- Deleting the branch tears the preview down.
14+
- No secrets land in the repository: workflow runs authenticate through GitHub's OIDC tokens.
15+
16+
## How the pieces fit
17+
18+
Push-to-deploy is two complementary halves, and you set up both:
19+
20+
1. **The repository connection** ([`git connect`](/cli/v8/git)) installs the Prisma GitHub App and registers the repository against your project. That enables the **credential exchange**, so your GitHub Actions runs can trade their OIDC token for a short-lived workspace token, and the **branch lifecycle automation**, so deleting a Git branch tears down the matching preview.
21+
2. **The deploy workflow** ([prisma/cloud-deploy-action](https://github.com/prisma/cloud-deploy-action)) runs in your own repository's GitHub Actions. On every push it installs dependencies, runs your build, and hands the result to the [`deploy` command](/cli/v8/deploy), targeting production or a stage named after the branch.
22+
23+
Each half is inert without the other. A connection with no workflow deploys nothing: connecting wires up automation, it doesn't build your commits. A workflow with no connection stays green but skips: without a credential the action reports `skipped-no-credential` and exits successfully, which is also why the workflow is harmless on forks.
24+
25+
There are two ways in. Connecting through the [Console](https://pris.ly/pdp) opens a pull request that adds the workflow for you, so both halves arrive together. Connecting from the CLI, as this guide does, sets up the connection only: you add the workflow file yourself in step 4.
26+
27+
## Prerequisites
28+
29+
- A Composer app that builds and deploys from your machine. If you don't have one yet, the [full-stack tutorial](/full-stack-tutorial) gets you there in about 15 minutes.
30+
- Admin access to the GitHub repository, so you can install the Prisma GitHub App.
31+
32+
## 1. Push the project to GitHub
33+
34+
If the app isn't on GitHub yet, create a repository from the project directory and push it. With the [GitHub CLI](https://cli.github.com/):
35+
36+
```bash
37+
gh repo create my-app --private --source . --push
38+
```
39+
40+
## 2. Link the directory to the project
41+
42+
The `git` commands operate on the project this directory is linked to. If you already deployed from this directory, it is linked. Otherwise, link it to the project your deploys created:
43+
44+
```npm
45+
npx prisma@next project link my-app
46+
```
47+
48+
Run this in the project root, next to `package.json` and `module.ts`. Linking pins the **current** directory (in a gitignored `.prisma/local.json`), and it will happily pin a parent directory without a warning; commands run from the project then fail with `PROJECT.SETUP_REQUIRED`. See the [`project` command reference](/cli/v8/project) for how the link is resolved.
49+
50+
## 3. Connect the repository
51+
52+
```npm
53+
npx prisma@next git connect https://github.com/you/my-app
54+
```
55+
56+
The command opens the browser to install the Prisma GitHub App on the repository if it isn't installed yet, then registers the connection. It needs you at the terminal: the install flow is interactive, and `--no-interactive` fails with `CLI.INTERACTION_REQUIRED` rather than printing an install URL to follow later. If you can't run it interactively, connect the repository through the [Console](https://pris.ly/pdp) instead.
57+
58+
Connecting the CLI way does not add a workflow to the repository, and it does not deploy anything on its own. That's the next step.
59+
60+
## 4. Add the deploy workflow
61+
62+
Commit a workflow that runs [prisma/cloud-deploy-action](https://github.com/prisma/cloud-deploy-action) on every push:
63+
64+
```yaml title=".github/workflows/prisma-deploy.yml"
65+
name: prisma-deploy
66+
67+
on:
68+
push:
69+
70+
concurrency:
71+
group: prisma-deploy-${{ github.ref }}
72+
cancel-in-progress: false
73+
74+
permissions:
75+
contents: read
76+
id-token: write
77+
78+
jobs:
79+
deploy:
80+
if: github.ref_type == 'branch'
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
- uses: actions/setup-node@v4
85+
with:
86+
node-version: 22
87+
- uses: oven-sh/setup-bun@v2
88+
- uses: prisma/cloud-deploy-action@v1
89+
with:
90+
build-command: npm run build
91+
```
92+
93+
Three lines carry the weight:
94+
95+
- **`id-token: write`** lets the job request an OIDC token from GitHub. The action exchanges it for a Prisma workspace token that expires after 30 minutes. That exchange only succeeds for the repository you connected in step 3, and it is the reason the workflow needs no secrets.
96+
- **`build-command`** is your build, run verbatim. The action never guesses how to build your app; a repository that runs its source directly sets `build-command: none`.
97+
- **`oven-sh/setup-bun@v2`** puts Bun on the runner PATH, which the action requires.
98+
99+
The action deploys with the repository's own installed `prisma` version when it finds one, so keep your `prisma` devDependency current. The action's [README](https://github.com/prisma/cloud-deploy-action) documents every input, including `module` for an entry file that isn't `module.ts` and `working-directory` for monorepos.
100+
101+
## 5. Push to deploy production
102+
103+
Commit the workflow and push to your default branch. In the repository's **Actions** tab, the `prisma-deploy` run installs, builds, and deploys, and ends by printing the same deploy report you know from your terminal, public URL included:
104+
105+
```text no-copy
106+
my-app
107+
├─ db postgres-database db_def456
108+
└─ api compute-service cps_abc123
109+
https://xyz.ewr.prisma.build
110+
```
111+
112+
From here on, the default branch is your production pipeline: every push to it deploys production, and re-deploys are idempotent updates, exactly as if you had run `deploy module.ts` yourself.
113+
114+
## 6. Preview a branch
115+
116+
Push any other branch:
117+
118+
```bash
119+
git switch -c feature/search
120+
git push -u origin feature/search
121+
```
122+
123+
The action deploys it as a [stage](/composer/deploying#production-and-stages) named after the branch, which is a [preview branch](/compute/branching) of the same project: its own compute services, its own databases (assigned to the preview branch, not production), its own buckets, and its own URL. The only thing it shares with production is the code. Inspect it like any branch:
124+
125+
```npm
126+
npx prisma@next service list --branch feature/search
127+
```
128+
129+
Iterate on the branch and every push updates the same preview. The preview's configuration comes from the branch's [environment variables](/compute/environment-variables), so a preview never reads production values.
130+
131+
## 7. Delete the branch to clean up
132+
133+
```bash
134+
git push origin --delete feature/search
135+
```
136+
137+
The platform's branch automation, wired up by `git connect` in step 3, tears down the matching preview: services, databases, and buckets are removed. Teardown comes from the repository connection, not from the workflow, so it works even when no Actions run fires for the deletion. Your production and default branches are never touched by automated cleanup.
138+
139+
## Forks and unconnected repositories
140+
141+
GitHub does not mint OIDC tokens for workflow runs triggered from forks, and the credential exchange refuses repositories that aren't connected. In both cases the action skips instead of failing: the run stays green, prints a notice, and sets its `outcome` output to `skipped-no-credential`. Contributors can fork your repository without their pushes failing CI or reaching your workspace.
142+
143+
## Troubleshooting
144+
145+
- **The deploy step fails with `CLI.UNKNOWN_COMMAND`.** The action release predates the unified CLI: releases up to v1.5.0 invoke the `prisma composer` subcommands, which were removed in `prisma` `8.0.0-rc.8`. Use a release that invokes the top-level `deploy` command (see the action's [releases](https://github.com/prisma/cloud-deploy-action/releases)).
146+
- **Commands fail with `PROJECT.SETUP_REQUIRED`.** The directory isn't linked, or you linked a parent directory. Re-run `project link` in the project root (step 2).
147+
- **`git connect` fails with `CLI.INTERACTION_REQUIRED`.** The command can't complete non-interactively. Run it at a terminal, or connect through the [Console](https://pris.ly/pdp).
148+
- **Runs are green but nothing deploys.** Check the run's log for `skipped-no-credential`: the repository isn't connected (step 3), or the run came from a fork.
149+
150+
## Next steps
151+
152+
- [GitHub integration](/compute/github): what the repository connection is and does.
153+
- [Branching](/compute/branching): how preview branches relate to Git branches.
154+
- [Deploying](/composer/deploying): stages, deploy state, and per-stage secrets, which all apply to CI deploys.
155+
- [Environment variables](/compute/environment-variables): per-branch configuration for previews.

apps/docs/content/docs/compute/deployments.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A deploy produces a **version** of a service: one built artifact that can serve
1212

1313
Versions are created three ways:
1414

15-
- **A git push.** After you [connect a GitHub repository](/compute/github), pushing a branch builds and deploys it: the default Git branch deploys to production, and every other branch gets an isolated preview.
15+
- **A git push.** After you [set up deploy on push](/compute/deploy-on-push), your repository's GitHub Actions workflow builds and deploys each pushed branch: the default Git branch deploys to production, and every other branch gets an isolated preview.
1616
- **The [Console](https://pris.ly/pdp).** Trigger a build and deploy from the browser.
1717
- **[`deploy`](/cli/v8/deploy).** For a [Prisma Composer](/composer) app, `deploy` assembles the services you have already built and provisions them from your terminal or CI.
1818

@@ -80,6 +80,6 @@ This permanently deletes the service from the branch you target with `--branch`.
8080
## Next steps
8181

8282
- [Environment variables](/compute/environment-variables): persist config across deploys.
83-
- [GitHub integration](/compute/github): the push-to-deploy flow in detail.
83+
- [Deploy on push](/compute/deploy-on-push): the push-to-deploy flow in detail.
8484
- [Domains](/compute/domains): point a custom domain at production.
8585
- [Prisma Composer](/composer): declare the app the `deploy` command deploys.

0 commit comments

Comments
 (0)