You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c44f72b
Browse filesBrowse the repository at this point in the historyBrowse files
For this workflow to work, you need to set the following secrets in your GitHub repository:
130
130
131
-
- `TRIGGER_ACCESS_TOKEN`: A Trigger.dev personal access token (they start with `tr_pat_`). [Learn how to create one and set it in GitHub](/github-actions#creating-a-personal-access-token).
131
+
- `TRIGGER_PREVIEW_ACCESS_TOKEN`: A Trigger.dev API key for the Preview environment with **Deploy only** access. [Create a deployment API key and add it to GitHub](/github-actions#create-a-deployment-api-key).
132
132
133
133
Notice that the deploy command has `--env preview` at the end. We automatically detect the preview branch from the GitHub actions env var.
Copy file name to clipboardExpand all lines: docs/github-actions.mdx
+24-14Lines changed: 24 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
2
title: "CI / GitHub Actions"
3
-
description: "You can easily deploy your tasks with GitHub actions and other CI environments."
3
+
description: "Deploy your tasks from GitHub Actions and other CI environments using an environment API key."
4
4
---
5
5
6
-
The instructions below are specific to GitHub Actions, but the same concepts can be used with other CI systems.
6
+
The instructions below are specific to GitHub Actions, but the same concepts apply to other CI systems. Use an environment API key rather than a Personal Access Token so deployments are not tied to an individual team member's account or permissions.
7
7
8
8
<Tip>
9
9
Check out our new [GitHub integration](/github-integration) for automatic deployments, without adding any GitHub Actions workflows.
On `pull_request`, `github.sha` is the merge commit GitHub creates for the PR, not the commit your
@@ -146,26 +146,36 @@ deployment sends.
146
146
**Include `closed`** in the `pull_request.types` list. Without it, preview branches won't be archived when PRs are merged or closed, and you may hit the limit on active preview branches. See [Preview branches](/deployment/preview-branches#preview-branches-with-github-actions-recommended) for more details.
147
147
</Note>
148
148
149
-
## Creating a Personal Access Token
149
+
## Create a deployment API key
150
+
151
+
Create a separate API key for each environment that your CI workflows deploy to. The key remains valid when team membership or permissions change.
150
152
151
153
<Steps>
152
154
153
-
<Step title="Create a new access token">
154
-
Go to your profile page and click on the ["Personal Access
Select the project and target environment, then open [**API keys**](https://cloud.trigger.dev/_/apikeys).
156
157
</Step>
157
158
158
-
<Step title="Go to your repository on GitHub.">
159
-
Click on 'Settings' -> 'Secrets and variables' -> 'Actions' -> 'New repository secret'
159
+
<Step title="Create an API key">
160
+
Click **New API key**, give the key a name that identifies the workflow, and choose **Deploy
161
+
only** access.
160
162
</Step>
161
163
162
-
<Step title="Add the TRIGGER_ACCESS_TOKEN">
163
-
Add the name `TRIGGER_ACCESS_TOKEN` and the value of your access token. 
164
+
<Step title="Copy the API key">
165
+
Create the key and copy its value. Trigger.dev shows the complete value only once.
166
+
</Step>
167
+
168
+
<Step title="Add the TRIGGER_ACCESS_TOKEN secret to GitHub">
169
+
Open the repository's **Settings**, then select **Secrets and variables** → **Actions** → **New
170
+
repository secret**. Add the name `TRIGGER_ACCESS_TOKEN` and paste the API key as its value.
171
+
172
+

165
173
</Step>
166
174
167
175
</Steps>
168
176
177
+
The API key must belong to the environment targeted by the deploy command. If the repository deploys to multiple environments, store each environment's key in a separate GitHub secret and map the appropriate secret to `TRIGGER_ACCESS_TOKEN` in each workflow.
178
+
169
179
## CLI Version pinning
170
180
171
181
The CLI and `@trigger.dev/*` package versions need to be in sync with the `trigger.dev` CLI, otherwise there will be errors and unpredictable behavior. Hence, the `deploy` command will automatically fail during CI on any version mismatches.
@@ -178,7 +188,7 @@ Tip: add the `trigger.dev` CLI to your `devDependencies` and the deploy command
0 commit comments