-
Notifications
You must be signed in to change notification settings - Fork 4
165 lines (146 loc) · 5.99 KB
/
deploy-docs-bundle-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Deploy @fern-docs/bundle
on:
push:
tags:
- ui@*
concurrency:
group: app.buildwithfern.com
cancel-in-progress: true
jobs:
deploy_app_buildwithfern_com:
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && github.event_name == 'push'
environment:
name: Production - app.buildwithfern.com
url: ${{ steps.deploy.outputs.deployment_url }}
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy app.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }} --environment=production
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
deploy_app_ferndocs_com:
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && github.event_name == 'push'
environment:
name: Production - app.ferndocs.com
url: ${{ steps.deploy.outputs.deployment_url }}
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy app.ferndocs.com --token=${{ secrets.VERCEL_TOKEN }} --environment=production
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
deploy_app-slash_ferndocs_com:
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && github.event_name == 'push'
environment:
name: Production - app-slash.ferndocs.com
url: ${{ steps.deploy.outputs.deployment_url }}
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy app-slash.ferndocs.com --token=${{ secrets.VERCEL_TOKEN }} --environment=production
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
# note: E2E tests should run before the deployment is promoted
# but currently tests that rely on javascript are not running successfully b/c of assetPrefix issues
# so we we are running the tests after the deployment is promoted for now
# TODO: Fix the tests and run them before promoting the deployment
ete:
needs:
- deploy_app_buildwithfern_com # only the app.buildwithfern.com deployment is an E2E candidate but ideally all deployments should be tested
- promote
if: needs.deploy_app_buildwithfern_com.outputs.deployment_url
uses: ./.github/workflows/playwright.yml
permissions: write-all
with:
deployment_url: ${{ needs.deploy_app_buildwithfern_com.outputs.deployment_url || '' }}
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
revalidate-all:
needs: promote
if: success()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: Revalidate all app.buildwithfern.com deployments
run: pnpm vercel-scripts revalidate-all app.buildwithfern.com --token ${{ secrets.VERCEL_TOKEN }}
rollback:
needs: ete
if: failure()
runs-on: ubuntu-latest
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: Rollback on failure # remove this step once we switch back to pre-promotion testing
run: |
echo "E2E tests failed. Rolling back deployment"
pnpm vercel-scripts rollback app.buildwithfern.com --token ${{ secrets.VERCEL_TOKEN }}
pnpm vercel-scripts rollback app.ferndocs.com --token ${{ secrets.VERCEL_TOKEN }}
pnpm vercel-scripts rollback app-slash.ferndocs.com --token ${{ secrets.VERCEL_TOKEN }}
# currently only the custom domains for app.buildwithfern.com deployment should be revalidated
# because the other deployments don't have custom domains (yet)
pnpm vercel-scripts revalidate-all app.buildwithfern.com --token ${{ secrets.VERCEL_TOKEN }}
echo "All docs deployments have been rolled back successfully!"
exit 1
promote:
needs:
- deploy_app_buildwithfern_com
- deploy_app_ferndocs_com
- deploy_app-slash_ferndocs_com
# - ete # Ensure that the E2E tests are run successful before promoting
runs-on: ubuntu-latest
strategy:
matrix:
deployment_url:
- ${{ needs.deploy_app_buildwithfern_com.outputs.deployment_url }}
- ${{ needs.deploy_app_ferndocs_com.outputs.deployment_url }}
- ${{ needs.deploy_app-slash_ferndocs_com.outputs.deployment_url }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: Promote Deployment
run: pnpm vercel-scripts promote ${{ matrix.deployment_url }} --token ${{ secrets.VERCEL_TOKEN }}
smoke-test:
needs: promote # Ensure that the deployment is promoted before running smoke tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Smoke Test
env:
NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }}
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
run: |
cd smoke-test
npm install -g fern-api
fern generate --docs --instance https://fern-platform-test.docs.buildwithfern.com
VALUE=$(curl https://fern-platform-test.docs.buildwithfern.com/api-reference/imdb/create-movie)
length=${#VALUE}
# Assert that length is over 1000
if [ $length -gt 1000 ]; then
echo "Length is greater than 1000"
else
exit 1
fi
healthchecks:
needs: promote # Ensure that the deployment is promoted before running healthchecks
uses: ./.github/workflows/healthcheck.yml
secrets: inherit