Skip to content

Commit 685325c

Browse files
authored
Deploy v2 to staging from main using a composite action (#2888)
1 parent ab132ea commit 685325c

File tree

2 files changed

+89
-42
lines changed

2 files changed

+89
-42
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'Deploy vercel'
2+
description: 'Deploy GitBook to Vercel'
3+
inputs:
4+
vercel-org:
5+
description: 'Vercel organization'
6+
required: true
7+
vercel-project:
8+
description: 'Vercel project'
9+
required: true
10+
vercel-token:
11+
description: 'Vercel token'
12+
required: true
13+
environment:
14+
description: 'Environment to deploy to'
15+
required: true
16+
outputs:
17+
deployment-url:
18+
description: "Deployment URL"
19+
value: ${{ steps.deploy.outputs.deployment-url }}
20+
runs:
21+
using: 'composite'
22+
steps:
23+
- name: Setup Bun
24+
uses: ./.github/composite/setup-bun
25+
- name: Install dependencies
26+
run: bun install --frozen-lockfile
27+
shell: bash
28+
env:
29+
PUPPETEER_SKIP_DOWNLOAD: 1
30+
- name: Sets env vars for environment
31+
shell: bash
32+
run: |
33+
echo "VERCEL_ENVIRONMENT=${{ inputs.environment }}" >> $GITHUB_ENV
34+
- name: Pull Vercel Environment Information
35+
run: bun run vercel pull --yes --environment=$VERCEL_ENVIRONMENT --token=${{ inputs.vercel-token }}
36+
shell: bash
37+
env:
38+
VERCEL_ORG_ID: ${{ inputs.vercel-org }}
39+
VERCEL_PROJECT_ID: ${{ inputs.vercel-project }}
40+
- name: Build Project Artifacts
41+
run: bun run vercel build --target=$VERCEL_ENVIRONMENT --token=${{ inputs.vercel-token }}
42+
shell: bash
43+
env:
44+
VERCEL_ORG_ID: ${{ inputs.vercel-org }}
45+
VERCEL_PROJECT_ID: ${{ inputs.vercel-project }}
46+
- name: Deploy Project Artifacts to Vercel
47+
id: deploy
48+
shell: bash
49+
run: |
50+
DEPLOYMENT_URL=$(bun run vercel deploy --prebuilt --target=$VERCEL_ENVIRONMENT --token=${{ inputs.vercel-token }})
51+
echo "deployment-url=$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT"
52+
env:
53+
VERCEL_ORG_ID: ${{ inputs.vercel-org }}
54+
VERCEL_PROJECT_ID: ${{ inputs.vercel-project }}
55+
- name: Outputs
56+
shell: bash
57+
run: |
58+
echo "URL: ${{ steps.deploy.outputs.deployment-url }}"

.github/workflows/ci.yaml

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -87,49 +87,41 @@ jobs:
8787
statuses: write
8888
outputs:
8989
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 }}
9390
steps:
9491
- name: Checkout
9592
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_URL=https://open-2v.gitbook.com" >> $GITHUB_ENV
107-
echo "GITBOOK_ASSETS_PREFIX=https://static-2v.gitbook.com" >> $GITHUB_ENV
108-
if: startsWith(github.ref, 'refs/heads/main')
109-
- name: Sets env vars for preview
110-
run: |
111-
echo "VERCEL_ENVIRONMENT=preview" >> $GITHUB_ENV
112-
echo "SENTRY_ENVIRONMENT=preview" >> $GITHUB_ENV
113-
if: 1 && !startsWith(github.ref, 'refs/heads/main')
114-
- name: Pull Vercel Environment Information
115-
run: bun run vercel pull --yes --environment=$VERCEL_ENVIRONMENT --token=${{ secrets.VERCEL_TOKEN }}
116-
- name: Build Project Artifacts
117-
run: bun run vercel build --target=$VERCEL_ENVIRONMENT --token=${{ secrets.VERCEL_TOKEN }}
118-
env:
119-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
120-
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: ${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
121-
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
122-
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
123-
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
124-
SENTRY_RELEASE: ${{ github.sha }}
125-
- name: Deploy Project Artifacts to Vercel
93+
- name: Deploy ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }}
12694
id: deploy
127-
run: |
128-
DEPLOYMENT_URL=$(bun run vercel deploy --prebuilt --target=$VERCEL_ENVIRONMENT --token=${{ secrets.VERCEL_TOKEN }})
129-
echo "deployment-url=$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT"
130-
- name: Outputs
131-
run: |
132-
echo "URL: ${{ steps.deploy.outputs.deployment-url }}"
95+
uses: ./.github/composite/deploy-vercel
96+
with:
97+
environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }}
98+
vercel-org: ${{ secrets.VERCEL_ORG_ID }}
99+
vercel-project: ${{ secrets.VERCEL_PROJECT_ID }}
100+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
101+
deploy-v2-vercel-staging:
102+
name: Deploy v2 to Vercel (staging)
103+
runs-on: ubuntu-latest
104+
permissions:
105+
contents: read
106+
deployments: write
107+
issues: write
108+
pull-requests: write
109+
checks: write
110+
statuses: write
111+
if: startsWith(github.ref, 'refs/heads/main')
112+
outputs:
113+
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@v4
117+
- name: Deploy staging
118+
id: deploy
119+
uses: ./.github/composite/deploy-vercel
120+
with:
121+
environment: staging
122+
vercel-org: ${{ secrets.VERCEL_ORG_ID }}
123+
vercel-project: ${{ secrets.VERCEL_PROJECT_ID }}
124+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
133125
deploy-v2-cloudflare:
134126
name: Deploy v2 to Cloudflare Worker
135127
runs-on: ubuntu-latest
@@ -142,9 +134,6 @@ jobs:
142134
statuses: write
143135
outputs:
144136
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
145-
env:
146-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
147-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
148137
steps:
149138
- name: Checkout
150139
uses: actions/checkout@v4

0 commit comments

Comments
 (0)