diff --git a/fern/products/docs/pages/changelog/2026-04-23.mdx b/fern/products/docs/pages/changelog/2026-04-23.mdx new file mode 100644 index 000000000..be0419e84 --- /dev/null +++ b/fern/products/docs/pages/changelog/2026-04-23.mdx @@ -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. + + diff --git a/fern/products/docs/pages/preview-publish/preview-changes-locally.mdx b/fern/products/docs/pages/preview-publish/preview-changes-locally.mdx index aedf64738..cd32726da 100644 --- a/fern/products/docs/pages/preview-publish/preview-changes-locally.mdx +++ b/fern/products/docs/pages/preview-publish/preview-changes-locally.mdx @@ -305,3 +305,35 @@ jobs: + +#### 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. + + +```yaml +name: Clean up preview links + +on: + pull_request: + types: [closed] + +jobs: + cleanup: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + 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" +``` +