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
The updated [GitLab CI/CD pipeline](/learn/docs/developer-tools/gitlab) now includes a `cleanup_preview` stage that deletes a merge request's preview deployment once the MR merges into the default branch, so stale previews don't linger.
8
+
9
+
To adopt this workflow, replace your `.gitlab-ci.yml` file with the updated version.
10
+
11
+
<Buttonintent="none"outlinedrightIcon="arrow-right"href="/learn/docs/developer-tools/git-lab#add-the-cicd-pipeline">Read the docs</Button>
Copy file name to clipboardExpand all lines: fern/products/docs/pages/developer-tools/gitlab.mdx
+32-9Lines changed: 32 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Set up GitLab CI/CD to automatically publish your Fern docs when ch
4
4
---
5
5
6
6
7
-
Use GitLab CI/CD to automatically generate preview links on merge requests and publish your Fern docs when changes are merged to `main`.
7
+
Use GitLab CI/CD to automatically generate preview links on merge requests, publish your Fern docs when changes are merged to `main`, and delete preview links after merge.
8
8
9
9
<Infotitle="Prerequisites">
10
10
- Node.js version 18 or higher
@@ -63,17 +63,18 @@ Save the generated token immediately — it won't be displayed after you leave t
63
63
64
64
## Add the CI/CD pipeline
65
65
66
-
Create a `.gitlab-ci.yml` file in the root of your repository. This pipeline validates your API definition, posts preview links on merge requests, and publishes your docs when changes are merged to `main`.
66
+
Create a `.gitlab-ci.yml` file in the root of your repository. This pipeline validates your API definition, posts a per-branch preview link on each merge request, publishes your docs when changes are merged to `main`, and deletes the merged branch's preview deployment.
echo "No merged MR found for this commit (likely a direct push to main) — skipping cleanup"
137
+
exit 0
138
+
fi
139
+
140
+
echo "Deleting preview for branch: $SOURCE_BRANCH"
141
+
fern docs preview delete --id "$SOURCE_BRANCH" || echo "Preview deletion returned non-zero — it may already be gone"
119
142
```
120
143
121
-
Commit and push the `.gitlab-ci.yml` file to your repository. The pipeline runs automatically when changes are merged to `main`.
144
+
Commit and push the `.gitlab-ci.yml` file to your repository. The pipeline runs automatically on merge requests and when changes are merged to your default branch.
0 commit comments