18
18
checks : write
19
19
statuses : write
20
20
outputs :
21
- deployment_url : ${{ steps.deploy.outputs.deployment-url }}
21
+ deployment-url : ${{ steps.deploy.outputs.deployment-url }}
22
+ deployment-alias-url : ${{ steps.deploy.outputs.deployment-alias-url }}
22
23
steps :
23
24
- name : Checkout
24
25
uses : actions/checkout@v4
38
39
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
39
40
if : 1 && !startsWith(github.ref, 'refs/heads/main')
40
41
- name : Build Next.js with next-on-pages
41
- run : bun run build:cloudflare
42
+ run : bun run turbo build:cloudflare
42
43
env :
43
44
SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
44
45
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY : ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
@@ -74,26 +75,163 @@ jobs:
74
75
-H "Accept: application/vnd.github.v3+json" \
75
76
-d '{"state": "success", "target_url": "${{ steps.deploy.outputs.deployment-url }}", "description": "Deployed Preview URL for commit", "context": "cloudflare/preview"}' \
76
77
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
77
-
78
+ deploy-v2-vercel :
79
+ name : Deploy v2 to Vercel
80
+ runs-on : ubuntu-latest
81
+ permissions :
82
+ contents : read
83
+ deployments : write
84
+ issues : write
85
+ pull-requests : write
86
+ checks : write
87
+ statuses : write
88
+ outputs :
89
+ deployment-url : ${{ steps.deploy.outputs.deployment-url }}
90
+ env :
91
+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
92
+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
93
+ steps :
94
+ - name : Checkout
95
+ uses : actions/checkout@v4
96
+ - name : Setup Bun
97
+ uses : ./.github/composite/setup-bun
98
+ - name : Install dependencies
99
+ run : bun install --frozen-lockfile
100
+ env :
101
+ PUPPETEER_SKIP_DOWNLOAD : 1
102
+ - name : Sets env vars for production
103
+ run : |
104
+ echo "VERCEL_ENVIRONMENT=production" >> $GITHUB_ENV
105
+ echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
106
+ echo "GITBOOK_ASSETS_PREFIX=https://static.gitbook.com" >> $GITHUB_ENV
107
+ if : startsWith(github.ref, 'refs/heads/main')
108
+ - name : Sets env vars for preview
109
+ run : |
110
+ echo "VERCEL_ENVIRONMENT=preview" >> $GITHUB_ENV
111
+ echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
112
+ if : 1 && !startsWith(github.ref, 'refs/heads/main')
113
+ - name : Pull Vercel Environment Information
114
+ run : bun run vercel pull --yes --environment=$VERCEL_ENVIRONMENT --token=${{ secrets.VERCEL_TOKEN }}
115
+ - name : Build Project Artifacts
116
+ run : bun run vercel build --token=${{ secrets.VERCEL_TOKEN }}
117
+ env :
118
+ SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
119
+ NEXT_SERVER_ACTIONS_ENCRYPTION_KEY : ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
120
+ SENTRY_ORG : ${{ vars.SENTRY_ORG }}
121
+ SENTRY_PROJECT : ${{ vars.SENTRY_PROJECT }}
122
+ SENTRY_DSN : ${{ vars.SENTRY_DSN }}
123
+ SENTRY_RELEASE : ${{ github.sha }}
124
+ - name : Deploy Project Artifacts to Vercel
125
+ id : deploy
126
+ run : |
127
+ DEPLOYMENT_URL=$(bun run vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
128
+ echo "deployment-url=$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT"
129
+ - name : Outputs
130
+ run : |
131
+ echo "URL: ${{ steps.deploy.outputs.deployment-url }}"
132
+ deploy-v2-cloudflare :
133
+ name : Deploy v2 to Cloudflare Worker
134
+ runs-on : ubuntu-latest
135
+ permissions :
136
+ contents : read
137
+ deployments : write
138
+ issues : write
139
+ pull-requests : write
140
+ checks : write
141
+ statuses : write
142
+ outputs :
143
+ deployment-url : ${{ steps.deploy.outputs.deployment-url }}
144
+ env :
145
+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
146
+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
147
+ steps :
148
+ - name : Checkout
149
+ uses : actions/checkout@v4
150
+ - name : Setup Bun
151
+ uses : ./.github/composite/setup-bun
152
+ - name : Install dependencies
153
+ run : bun install --frozen-lockfile
154
+ env :
155
+ PUPPETEER_SKIP_DOWNLOAD : 1
156
+ - name : Sets env vars for production
157
+ run : |
158
+ echo "SENTRY_ENVIRONMENT=production" >> $GITHUB_ENV
159
+ echo "GITBOOK_ASSETS_PREFIX=https://static.gitbook.com" >> $GITHUB_ENV
160
+ if : startsWith(github.ref, 'refs/heads/main')
161
+ - name : Sets env vars for preview
162
+ run : |
163
+ echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
164
+ if : 1 && !startsWith(github.ref, 'refs/heads/main')
165
+ - name : Build worker
166
+ run : bun run turbo build:v2:cloudflare
167
+ env :
168
+ SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
169
+ NEXT_SERVER_ACTIONS_ENCRYPTION_KEY : ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
170
+ SENTRY_ORG : ${{ vars.SENTRY_ORG }}
171
+ SENTRY_PROJECT : ${{ vars.SENTRY_PROJECT }}
172
+ SENTRY_DSN : ${{ vars.SENTRY_DSN }}
173
+ SENTRY_RELEASE : ${{ github.sha }}
174
+ - id : deploy
175
+ name : Deploy to Cloudflare
176
+ uses :
cloudflare/[email protected]
177
+ with :
178
+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
179
+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
180
+ workingDirectory : ./
181
+ wranglerVersion : ' 3.82.0'
182
+ command : versions upload --config ./packages/gitbook-v2/wrangler.toml
183
+ - name : Outputs
184
+ run : |
185
+ echo "URL: ${{ steps.deploy.outputs.deployment-url }}"
186
+ comment-deployments :
187
+ runs-on : ubuntu-latest
188
+ name : Comment Deployments
189
+ if : always() && !startsWith(github.ref, 'refs/heads/main')
190
+ needs :
191
+ - deploy
192
+ - deploy-v2-vercel
193
+ - deploy-v2-cloudflare
194
+ steps :
195
+ - name : Checkout
196
+ uses : actions/checkout@v4
197
+ - name : Setup Bun
198
+ uses : ./.github/composite/setup-bun
78
199
- name : Find GitHub Comment
79
200
uses : peter-evans/find-comment@v3
80
201
id : fc
81
- if : 1 && !startsWith(github.ref, 'refs/heads/main')
82
202
with :
83
203
issue-number : ${{ github.event.pull_request.number }}
84
204
comment-author : ' github-actions[bot]'
85
- body-includes : GitBook Preview
205
+ body-includes : ' Summary of the deployments '
86
206
87
207
- name : Create or update GitHub comment
88
208
uses : peter-evans/create-or-update-comment@v4
89
- if : 1 && !startsWith(github.ref, 'refs/heads/main')
90
209
with :
91
210
comment-id : ${{ steps.fc.outputs.comment-id }}
92
211
issue-number : ${{ github.event.pull_request.number }}
93
212
body : |
94
- **GitBook Preview**
95
- Latest commit: [${{ steps.deploy.outputs.deployment-url }}](${{ steps.deploy.outputs.deployment-url }})
96
- PR: [${{ steps.deploy.outputs.deployment-alias-url }}](${{ steps.deploy.outputs.deployment-alias-url }})
213
+ Summary of the deployments:
214
+
215
+ ### Version 1 (production)
216
+
217
+ | Version | URL | Status |
218
+ | --- | --- | --- |
219
+ | Latest commit | [${{ needs.deploy.outputs.deployment-url }}](${{ needs.deploy.outputs.deployment-url }}) | ${{ needs.deploy.result == 'success' && '✅' || '❌' }} |
220
+ | PR | [${{ needs.deploy.outputs.deployment-alias-url }}](${{ needs.deploy.outputs.deployment-alias-url }}) | ${{ needs.deploy.result == 'success' && '✅' || '❌' }} |
221
+
222
+ ### Version 2 (experimental)
223
+
224
+ | Version | URL | Status |
225
+ | --- | --- | --- |
226
+ | Vercel | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}](${{ needs.deploy-v2-vercel.outputs.deployment-url }}) | ${{ needs.deploy-v2-vercel.result == 'success' && '✅' || '❌' }} |
227
+ | Cloudflare | [${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}](${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}) | ${{ needs.deploy-v2-cloudflare.result == 'success' && '✅' || '❌' }} |
228
+
229
+ ### Test content
230
+
231
+ | Site | v1 | v2 |
232
+ | --- | --- | --- |
233
+ | GitBook | [${{ needs.deploy.outputs.deployment-url }}/docs.gitbook.com](${{ needs.deploy.outputs.deployment-url }}/docs.gitbook.com) | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/docs.gitbook.com](${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/docs.gitbook.com) |
234
+ | E2E | [${{ needs.deploy.outputs.deployment-url }}/gitbook.gitbook.io/test-gitbook-open](${{ needs.deploy.outputs.deployment-url }}/gitbook.gitbook.io/test-gitbook-open) | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/gitbook.gitbook.io/test-gitbook-open](${{ needs.deploy-v2-vercel.outputs.deployment-url }}/static/url/gitbook.gitbook.io/test-gitbook-open) |
97
235
edit-mode : replace
98
236
visual-testing :
99
237
runs-on : ubuntu-latest
@@ -111,7 +249,7 @@ jobs:
111
249
- name : Run Playwright tests
112
250
run : bun e2e
113
251
env :
114
- BASE_URL : ${{needs.deploy.outputs.deployment_url }}
252
+ BASE_URL : ${{needs.deploy.outputs.deployment-url }}
115
253
ARGOS_TOKEN : ${{ secrets.ARGOS_TOKEN }}
116
254
- uses : actions/upload-artifact@v4
117
255
if : ${{ !cancelled() }}
@@ -135,7 +273,7 @@ jobs:
135
273
- name : Run pagespeed tests
136
274
run : bun ./packages/gitbook/tests/pagespeed-testing.ts $DEPLOYMENT_URL
137
275
env :
138
- DEPLOYMENT_URL : ${{needs.deploy.outputs.deployment_url }}
276
+ DEPLOYMENT_URL : ${{needs.deploy.outputs.deployment-url }}
139
277
PAGESPEED_API_KEY : ${{ secrets.PAGESPEED_API_KEY }}
140
278
format :
141
279
runs-on : ubuntu-latest
0 commit comments