Skip to content

Commit 0cabbdd

Browse files
authored
docs: deploying using the github integration (#2598)
* docs: deploying using the github integration * Add hint in the gh actions docs page * Remove extra space * Add a couple of hints to the build config fields
1 parent f8977a7 commit 0cabbdd

File tree

6 files changed

+142
-6
lines changed

6 files changed

+142
-6
lines changed

apps/webapp/app/routes/_app.github.callback/route.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
3737
logger.warn("GitHub App callback with invalid params", {
3838
queryParams,
3939
});
40-
return redirectWithErrorMessage("/", request, "Failed to install GitHub App");
40+
return redirectWithErrorMessage("/", request, "Failed to install GitHub app");
4141
}
4242

4343
const callbackData = result.data;
@@ -50,7 +50,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
5050
error: sessionResult.error,
5151
});
5252

53-
return redirectWithErrorMessage("/", request, "Failed to install GitHub App");
53+
return redirectWithErrorMessage("/", request, "Failed to install GitHub app");
5454
}
5555

5656
const { organizationId, redirectTo: unsafeRedirectTo } = sessionResult;
@@ -72,7 +72,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
7272
userId: user.id,
7373
organizationId,
7474
});
75-
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub App");
75+
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub app");
7676
}
7777

7878
switch (callbackData.setup_action) {
@@ -85,7 +85,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
8585
logger.error("Failed to link GitHub App installation", {
8686
error,
8787
});
88-
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub App");
88+
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub app");
8989
}
9090

9191
return redirectWithSuccessMessage(redirectTo, request, "GitHub App installed successfully");
@@ -116,6 +116,6 @@ export async function loader({ request }: LoaderFunctionArgs) {
116116

117117
default:
118118
callbackData satisfies never;
119-
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub App");
119+
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub app");
120120
}
121121
}

docs/deployment/connect-repo.png

460 KB
Loading

docs/deployment/git-settings.png

440 KB
Loading

docs/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"deployment/atomic-deployment",
112112
{
113113
"group": "Deployment integrations",
114-
"pages": ["vercel-integration"]
114+
"pages": ["github-integration", "vercel-integration"]
115115
}
116116
]
117117
},

docs/github-actions.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ description: "You can easily deploy your tasks with GitHub actions and other CI
55

66
The instructions below are specific to GitHub Actions, but the same concepts can be used with other CI systems.
77

8+
<Tip>
9+
Check out our new [GitHub integration](/github-integration) for automatic deployments, without adding any GitHub Actions workflows.
10+
</Tip>
11+
812
## GitHub Actions example
913

1014
This simple GitHub action workflow will deploy your Trigger.dev tasks when new code is pushed to the `main` branch and the `trigger` directory has changes in it.

docs/github-integration.mdx

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: "GitHub integration"
3+
description: "Automatically deploy your tasks on every push to your GitHub repository."
4+
---
5+
6+
## How it works
7+
8+
Once you connect a GitHub repository to your project, you can configure tracking branches for the production and staging environments.
9+
Every push to a tracked branch creates a deployment in the corresponding environment. Preview branch deployments are also supported for pull requests.
10+
11+
This eliminates the need to manually run the `trigger.dev deploy` command or set up custom CI/CD workflows.
12+
13+
## Setup
14+
15+
<Steps>
16+
17+
<Step title="Install our GitHub app">
18+
Go to your project's settings page and click `Install GitHub app`.
19+
This will take you to GitHub to authorize the Trigger.dev app for your organization or personal account.
20+
</Step>
21+
22+
<Step title="Connect your repository">
23+
Select a repository to connect to your project.
24+
</Step>
25+
26+
<Step title="Configure branch tracking">
27+
Choose which branches should trigger automatic deployments:
28+
29+
- **Production**: The branch that deploys to your production environment, e.g., `main`.
30+
- **Staging**: The branch that deploys to your staging environment.
31+
- **Preview**: Toggle to enable preview deployments for pull requests
32+
</Step>
33+
34+
<Step title="Customize build settings (optional)">
35+
Configure how your project is built:
36+
37+
- **Trigger config file**: Path to your `trigger.config.ts` file. By default, we look for it in the root of your repository. The path should be relative to the root of your repository and contain the config file name, e.g., `apps/tasks/trigger.config.ts`.
38+
- **Install command**: Auto-detected by default, but you can override it if necessary. The command will be run from the root of your repository.
39+
- **Pre-build command**: Run any commands before building and deploying your project, e.g., `pnpm run prisma:generate`. The command will be run from the root of your repository.
40+
</Step>
41+
42+
</Steps>
43+
44+
## Branch tracking
45+
46+
Our GitHub integration uses branch tracking to determine when and where to deploy your code.
47+
48+
![Trigger.dev project git settings](/deployment/git-settings.png)
49+
50+
### Production and staging branches
51+
52+
When you connect a repository, the default branch of your repository will be used as the production tracking branch, by default.
53+
54+
When you configure a production or staging branch, every push to that branch will trigger a deployment.
55+
Our build server will install the project dependencies, build your project, and deploy it to the corresponding environment.
56+
57+
If there are multiple consecutive pushes to a tracked branch, the later deployments will be queued until the previous deployment completes.
58+
59+
<Note>
60+
When you connect a repository, the default branch of your repository will be used as the production tracking branch by default.
61+
You can change this in the git settings of your project.
62+
</Note>
63+
64+
### Pull requests
65+
66+
By default, pull requests will be deployed to preview branch environments, enabling you to test changes before merging.
67+
When the pull request is merged or closed, the preview branch is automatically archived.
68+
69+
The name of the preview branch matches the branch name of the pull request.
70+
71+
<Note>
72+
Preview branch deployments require the preview environment to be enabled on your project. Learn more about [preview branches](/deployment/preview-branches).
73+
</Note>
74+
75+
## Disconnecting a repository
76+
77+
You can disconnect a repository at any time from your project git settings. This will stop automatic deployments triggered from GitHub.
78+
79+
## Managing repository access
80+
81+
To add or remove repository access for the Trigger.dev GitHub app, follow the link in the `Connect GitHub repository` modal:
82+
83+
![Trigger.dev prompt to connect a GitHub repository](/deployment/connect-repo.png)
84+
85+
Alternatively, you can follow these steps on GitHub:
86+
87+
1. Go to your GitHub account settings
88+
2. Navigate to **Settings****Applications****Installed GitHub Apps**
89+
3. Click **Configure** next to `Trigger.dev App`
90+
4. Update repository access under `Repository access`
91+
92+
Changes to repository access will be reflected immediately in your Trigger.dev project settings.
93+
94+
## Environment variables at build time
95+
96+
You can expose environment variables during the build and deployment process by prefixing them with `TRIGGER_BUILD_`.
97+
Build extensions will also have access to these variables.
98+
99+
Build environment variables only apply to deployments in the environment you set them in.
100+
101+
Learn more about managing [environment variables](/deploy-environment-variables).
102+
103+
## Using a private npm registry
104+
105+
If your project uses packages from a private npm registry, you can provide authentication by setting a `TRIGGER_BUILD_NPM_RC` environment variable.
106+
107+
The value should be the contents of your `.npmrc` file including any token credentials, encoded to base64.
108+
109+
### Example
110+
111+
Example `.npmrc` file containing credentials for a private npm registry and a GitHub package registry:
112+
113+
```
114+
//registry.npmjs.org/:_authToken=<YOUR_NPM_TOKEN>
115+
@<YOUR_NAMESPACE>:registry=https://npm.pkg.github.com
116+
//npm.pkg.github.com/:always-auth=true
117+
//npm.pkg.github.com/:_authToken=<YOUR_GITHUB_TOKEN>
118+
```
119+
120+
Encode it to base64:
121+
122+
```bash
123+
# Encode your .npmrc file
124+
cat .npmrc | base64
125+
```
126+
127+
Then, set the `TRIGGER_BUILD_NPM_RC` environment variable in your project settings with the encoded value.
128+
129+
<Note>
130+
The build server will automatically create a `.npmrc` file in the installation directory based on the content of the `TRIGGER_BUILD_NPM_RC` environment variable.
131+
This enables the build server to authenticate to your private npm registry.
132+
</Note>

0 commit comments

Comments
 (0)