Skip to content

Commit 307bb09

Browse files
committed
added preview branches section to github actions
1 parent 27d0817 commit 307bb09

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

docs/deployment/preview-branches.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ This GitHub Action will:
7272

7373
1. Automatically create a preview branch for your Pull Request (if the branch doesn't already exist).
7474
2. Deploy the preview branch.
75-
3. Archive the preview branch when the Pull Request is merged/closed.
75+
3. Archive the preview branch when the Pull Request is merged/closed. This only works if your workflow runs on **closed** PRs (`types: [opened, synchronize, reopened, closed]`). If you omit `closed`, branches won't be archived automatically.
7676

7777
```yml .github/workflows/trigger-preview-branches.yml
7878
name: Deploy to Trigger.dev (preview branches)

docs/github-actions.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,41 @@ jobs:
8383
8484
If you already have a GitHub action file, you can just add the final step "🚀 Deploy Trigger.dev" to your existing file.
8585
86+
## Preview branches
87+
88+
To deploy to preview branches from Pull Requests and have them archived when PRs are merged or closed, use a workflow that runs on `pull_request` with **all four types** including `closed`:
89+
90+
```yaml .github/workflows/trigger-preview-branches.yml
91+
name: Deploy to Trigger.dev (preview branches)
92+
93+
on:
94+
pull_request:
95+
types: [opened, synchronize, reopened, closed]
96+
97+
jobs:
98+
deploy-preview:
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: Use Node.js 20.x
104+
uses: actions/setup-node@v4
105+
with:
106+
node-version: "20.x"
107+
108+
- name: Install dependencies
109+
run: npm install
110+
111+
- name: Deploy preview branch
112+
run: npx trigger.dev@latest deploy --env preview
113+
env:
114+
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
115+
```
116+
117+
<Note>
118+
**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.
119+
</Note>
120+
86121
## Creating a Personal Access Token
87122

88123
<Steps>

0 commit comments

Comments
 (0)