Skip to content

Commit 776ab50

Browse files
ci(web): add manual production redeploy workflow (#3664)
1 parent cf23ef9 commit 776ab50

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

.github/workflows/redeploy-web.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Redeploy Web to Production
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
concurrency:
10+
group: deploy-production
11+
cancel-in-progress: false
12+
13+
env:
14+
VERCEL_VERSION: '53.3.1'
15+
16+
jobs:
17+
verify-main:
18+
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
19+
timeout-minutes: 5
20+
21+
steps:
22+
- name: Verify main branch
23+
run: |
24+
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
25+
echo "::error::This workflow must be run from main. Got: $GITHUB_REF"
26+
exit 1
27+
fi
28+
29+
deploy-app:
30+
needs: verify-main
31+
runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }}
32+
timeout-minutes: 30
33+
environment: production
34+
35+
env:
36+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
37+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_APP }}
38+
39+
steps:
40+
- name: Checkout code
41+
uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
42+
with:
43+
lfs: true
44+
45+
- name: Setup pnpm
46+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
50+
with:
51+
node-version-file: '.nvmrc'
52+
cache: 'pnpm'
53+
54+
- name: Install dependencies
55+
run: pnpm install --frozen-lockfile
56+
57+
- name: Cache Next.js build
58+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
59+
with:
60+
path: |
61+
~/.npm
62+
${{ github.workspace }}/apps/web/.next/cache
63+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
64+
restore-keys: |
65+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
66+
67+
- run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} link --project=kilocode-app --token=${{ secrets.VERCEL_TOKEN }} --yes
68+
69+
- name: Pull Vercel Environment Information
70+
run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
71+
72+
- name: Build Project Artifacts
73+
env:
74+
NODE_OPTIONS: '--max-old-space-size=8192'
75+
run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} build --prod --token=${{ secrets.VERCEL_TOKEN }}
76+
77+
- name: Deploy Project Artifacts to Vercel
78+
run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
79+
80+
deploy-global-app:
81+
needs: verify-main
82+
runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }}
83+
timeout-minutes: 30
84+
environment: production
85+
86+
env:
87+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
88+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_GLOBAL_APP }}
89+
90+
steps:
91+
- name: Checkout code
92+
uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
93+
with:
94+
lfs: true
95+
96+
- name: Setup pnpm
97+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
98+
99+
- name: Setup Node.js
100+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
101+
with:
102+
node-version-file: '.nvmrc'
103+
cache: 'pnpm'
104+
105+
- name: Install dependencies
106+
run: pnpm install --frozen-lockfile
107+
108+
- name: Cache Next.js build
109+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
110+
with:
111+
path: |
112+
~/.npm
113+
${{ github.workspace }}/apps/web/.next/cache
114+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
115+
restore-keys: |
116+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
117+
118+
- run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} link --project=kilocode-global-app --token=${{ secrets.VERCEL_TOKEN }} --yes
119+
120+
- name: Pull Vercel Environment Information
121+
run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
122+
123+
- name: Build Project Artifacts
124+
env:
125+
NODE_OPTIONS: '--max-old-space-size=8192'
126+
run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} build --prod --token=${{ secrets.VERCEL_TOKEN }}
127+
128+
- name: Deploy Project Artifacts to Vercel
129+
run: pnpm dlx vercel@${{ env.VERCEL_VERSION }} deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

0 commit comments

Comments
 (0)