Skip to content

Commit 1ce9388

Browse files
devin-ai-integration[bot]fern-supportdannysheridandevalog
authored
Add documentation for staging and production environments (#2901)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Fern Support <[email protected]> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Devin Logan <[email protected]>
1 parent 4f07d50 commit 1ce9388

File tree

1 file changed

+120
-9
lines changed

1 file changed

+120
-9
lines changed

fern/products/docs/pages/getting-started/publishing-your-docs.mdx

Lines changed: 120 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
title: Publishing your docs
33
---
44

5-
When you are ready for your docs to be publicly accessible, you can publish them using the Fern CLI.
5+
When you are ready for your docs to be publicly accessible, publish them using the Fern CLI. Choose one of the following approaches: publish [only to a production site](#publish-to-production), or [to separate staging and production sites](#publish-to-staging-and-production).
66

77
<Info>
88
Use the [Fern Dashboard](https://dashboard.buildwithfern.com) to manage CLI access and your GitHub repository connection.
99
</Info>
1010

11-
## Usage
11+
## Publish to production
12+
13+
For a single production site (no staging environment), run the following command to publish your documentation:
1214

1315
```bash
1416
fern generate --docs
1517
```
1618

17-
### Example
18-
19-
```bash
19+
```bash Example
2020
fern generate --docs
2121
[docs]: Found 0 errors and 1 warnings. Run fern check --warnings to print out the warnings.
2222
[docs]: ✓ All checks passed
@@ -26,8 +26,9 @@ fern generate --docs
2626
└─
2727
```
2828

29-
### Usage in GitHub Actions
30-
To automate the publishing process, you can use a GitHub Action workflow to publish your docs when a push is made to the `main` branch.
29+
<Accordion title="Automate publishing process">
30+
31+
Use a GitHub Action workflow to publish your docs when a push is made to the `main` branch.
3132

3233
<Steps>
3334
<Step title="Generate token">
@@ -66,14 +67,124 @@ jobs:
6667
```
6768
</Step>
6869
</Steps>
70+
</Accordion>
71+
72+
## Publish to staging and production
73+
74+
To preview changes on a staging site before publishing to production, define [multiple instances](/learn/docs/configuration/site-level-settings#instances-configuration) in your `docs.yml` file. Once you configure multiple instances, you must use the `--instance` flag when publishing.
75+
76+
<Steps>
77+
<Step title="Configure instances">
78+
79+
Add both staging and production URLs to your `docs.yml` file. Don't include `https://` in the URLs.
80+
81+
```yaml docs.yml
82+
instances:
83+
- url: plantstore-prod.docs.buildwithfern.com
84+
- url: plantstore-staging.docs.buildwithfern.com
85+
```
86+
</Step>
87+
<Step title="Publish to a specific instance">
88+
89+
Use the `--instance` flag to publish to a specific environment:
90+
91+
```bash
92+
# Publish to staging
93+
fern generate --docs --instance plantstore-staging.docs.buildwithfern.com
94+
95+
# Publish to production
96+
fern generate --docs --instance plantstore-prod.docs.buildwithfern.com
97+
```
98+
99+
After publishing, both instances will appear in the [Fern Dashboard](https://dashboard.buildwithfern.com).
100+
101+
</Step>
102+
</Steps>
103+
104+
<Accordion title="Automate publishing process">
105+
106+
Use GitHub Action workflows to automatically deploy to staging on every push, while keeping production deployments manual.
107+
108+
<Steps>
109+
<Step title="Generate token">
110+
<Markdown src="/snippets/fern-token.mdx" />
111+
</Step>
112+
<Step title="Add token as a secret">
113+
Add the token as a [repository secret](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) called `FERN_TOKEN`.
114+
</Step>
115+
<Step title="Set up automatic staging deployment workflow">
116+
117+
This workflow automatically publishes to your staging instance when changes are pushed to the `main` branch:
118+
119+
```yaml .github/workflows/publish-staging.yml maxLines=7
120+
name: Publish Staging Docs
121+
122+
on:
123+
workflow_dispatch:
124+
push:
125+
branches:
126+
- main
127+
128+
jobs:
129+
run:
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Checkout repository
133+
uses: actions/checkout@v4
134+
135+
- name: Install Fern
136+
run: npm install -g fern-api
137+
138+
- name: Validate configuration
139+
run: fern check
140+
141+
- name: Publish to Staging
142+
env:
143+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
144+
run: fern generate --docs --instance plantstore-staging.docs.buildwithfern.com
145+
```
146+
</Step>
147+
<Step title="Set up manual production deployment workflow">
148+
149+
This workflow allows you to manually trigger a production deployment from the GitHub Actions UI:
150+
151+
```yaml .github/workflows/publish-production.yml maxLines=7
152+
name: Publish Production Docs
153+
154+
on:
155+
workflow_dispatch:
156+
157+
jobs:
158+
run:
159+
runs-on: ubuntu-latest
160+
steps:
161+
- name: Checkout repository
162+
uses: actions/checkout@v4
163+
164+
- name: Install Fern
165+
run: npm install -g fern-api
166+
167+
- name: Validate configuration
168+
run: fern check
169+
170+
- name: Publish to Production
171+
env:
172+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
173+
run: fern generate --docs --instance plantstore-prod.docs.buildwithfern.com
174+
```
175+
176+
To deploy to production, go to the **Actions** tab in your GitHub repository, select the workflow, and click **Run workflow**.
177+
</Step>
178+
</Steps>
179+
</Accordion>
69180

70181
## Hosting
71182

72183
When you publish your docs, Fern takes care of hosting them for you. You can also [publish your docs to a custom domain](/docs/preview-publish/setting-up-your-domain).
73184

74185
### Self-hosting your docs
75186

76-
If you need access to your docs offline or would like to host your docs on your own server, Fern [offers that option as well](/docs/self-hosted/overview). Self-hosted docs have limited access to certain features (including Ask Fern and analytics).
187+
If you need access to your docs offline or would like to host your docs on your own server, Fern [offers that option as well](/docs/self-hosted/overview). Self-hosted docs have limited access to certain features (including Ask Fern and analytics).
77188

78189
## Unpublishing your docs
79190

@@ -93,4 +204,4 @@ navigation: []
93204

94205
Publish the updated configuration by running `fern generate --docs`. This will remove all content from your site, and users visiting any page will see a 404 error.
95206
</Step>
96-
</Steps>
207+
</Steps>

0 commit comments

Comments
 (0)