Skip to content

docs: add cleanup stage for preview deployments (gitlab)#5097

Merged
devalog merged 2 commits intomainfrom
devalog/gitlab-preview
Apr 22, 2026
Merged

docs: add cleanup stage for preview deployments (gitlab)#5097
devalog merged 2 commits intomainfrom
devalog/gitlab-preview

Conversation

@devalog
Copy link
Copy Markdown
Collaborator

@devalog devalog commented Apr 22, 2026

Summary

Updates the GitLab CI/CD guide to cover preview-link cleanup. The pipeline now deletes a merge
request's preview deployment once the MR merges into the default branch, so stale previews don't
linger.

Changes to fern/products/docs/pages/developer-tools/gitlab.mdx:

  • Adds a cleanup_preview stage that looks up the merged MR for the commit, extracts its source
    branch, and runs fern docs preview delete --id "$SOURCE_BRANCH".
  • Scopes preview generation per-branch via --id "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" --force, so
    each MR gets a stable preview URL that the cleanup step can target.
  • Replaces hardcoded "main" branch rules with $CI_DEFAULT_BRANCH so the pipeline works for repos
    whose default branch isn't main.
  • Installs jq in before_script (needed to parse the MR lookup response) and swaps grep -oP for
    grep -oE for portability.
  • Updates the intro, pipeline description, and closing paragraph to mention per-branch previews and
    preview deletion on merge.

Review & Testing Checklist for Human

  • Run the updated .gitlab-ci.yml against a real GitLab project: open an MR, confirm a preview
    link is posted, merge it, and confirm the cleanup_preview job deletes the preview.
  • Confirm the jq parse in cleanup_preview handles the "direct push to main" case
    gracefully (job should exit 0, not fail).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

@devalog devalog merged commit ef2d186 into main Apr 22, 2026
2 checks passed
@devalog devalog deleted the devalog/gitlab-preview branch April 22, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants