Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions fern/products/docs/pages/changelog/2026-04-23.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
tags: ["developer-tools"]
---

## Clean up GitHub Actions preview deployments on merge

The [GitHub Actions preview workflow](/learn/docs/preview-publish/preview-changes#automate-with-github-actions) now has an optional companion `cleanup-preview.yml` workflow that deletes a pull request's preview deployment once the PR merges, so stale previews don't linger.

To adopt this workflow, add `.github/workflows/cleanup-preview.yml` alongside your existing preview workflow.

<Button intent="none" outlined rightIcon="arrow-right" href="/learn/docs/preview-publish/preview-changes#clean-up-preview-links-when-prs-merge">Read the docs</Button>
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,35 @@ jobs:
</CodeBlock>

</Accordion>

#### Clean up preview links when PRs merge

To clean up preview links automatically after a PR is merged, add this workflow alongside the one above. It calls [`fern docs preview delete`](/learn/cli-api-reference/cli-reference/commands#fern-docs-preview-delete) with the PR's branch name as the `--id`, matching the identifier used when the preview was generated.

<CodeBlock title = ".github/workflows/cleanup-preview.yml">
```yaml
name: Clean up preview links

on:
pull_request:
types: [closed]

jobs:
cleanup:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[FernStyles.Current] Avoid time-relative terms like 'latest' that become outdated

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Fern CLI
uses: fern-api/setup-fern-cli@v1

- name: Delete preview deployment
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
echo "Deleting preview for branch: ${{ github.head_ref }}"
fern docs preview delete --id "${{ github.head_ref }}" || echo "Preview deletion returned non-zero — it may already be gone"
```
</CodeBlock>
Loading