Skip to content

Commit 273f3f1

Browse files
committed
feat: test
1 parent c327a6f commit 273f3f1

File tree

9 files changed

+888
-1
lines changed

9 files changed

+888
-1
lines changed

.env.staging

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Staging environment configuration
2+
MISTRAL_API_KEY="your_staging_mistral_api_key"
3+
NEXT_PUBLIC_BASE_URL="https://platform-docs-staging.vercel.app"
4+
NODE_ENV="staging"

.github/DEPLOYMENT_GUIDE.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# 🚀 Vercel Deployment Guide
2+
3+
This guide explains how to deploy the Mistral Platform Docs to Vercel using GitHub Actions.
4+
5+
## 🔑 Required Secrets
6+
7+
Before deploying, ensure these GitHub Secrets are set up in your repository:
8+
9+
| Secret Name | Description | Required |
10+
|-------------|-------------|----------|
11+
| `VERCEL_ORG_ID` | Vercel Organization ID | ✅ Yes |
12+
| `VERCEL_PROJECT_ID` | Vercel Project ID | ✅ Yes |
13+
| `VERCEL_TOKEN` | Vercel API Token | ✅ Yes |
14+
| `MISTRAL_API_KEY` | Mistral AI API Key | ✅ Yes |
15+
| `NEXT_PUBLIC_BASE_URL` | Production domain URL | ✅ Yes |
16+
17+
## 📋 Workflows
18+
19+
### 1. Production Deployment (`deploy_to_vercel.yml`)
20+
21+
**Triggers:**
22+
- Push to `main` branch
23+
- Pull requests to `main` branch
24+
25+
**Features:**
26+
- ✅ Automatic production deployment
27+
- ✅ Build caching for faster deployments
28+
- ✅ Environment variable management
29+
- ✅ Cleanup after deployment
30+
- ✅ Concurrency control (prevents duplicate deployments)
31+
32+
### 2. Preview Deployment (`deploy_preview.yml`)
33+
34+
**Triggers:**
35+
- Pull request opened
36+
- Pull request synchronized (new commits)
37+
- Pull request reopened
38+
39+
**Features:**
40+
- ✅ Automatic preview deployment for each PR
41+
- ✅ PR comment with preview URL
42+
- ✅ Auto-updates preview on new commits
43+
- ✅ Temporary deployments (deleted when PR closes)
44+
- ✅ Concurrency control per PR
45+
46+
## 🎯 Deployment Process
47+
48+
### Production Deployment
49+
50+
1. **Push to main branch**
51+
```bash
52+
git push origin main
53+
```
54+
55+
2. **GitHub Actions triggers** the `deploy_to_vercel.yml` workflow
56+
57+
3. **Workflow steps:**
58+
- Checkout code with submodules
59+
- Set up pnpm and Node.js
60+
- Install dependencies (cached)
61+
- Build Next.js application
62+
- Deploy to Vercel production
63+
64+
4. **Deployment complete** 🎉
65+
66+
### Preview Deployment
67+
68+
1. **Create or update a pull request**
69+
70+
2. **GitHub Actions triggers** the `deploy_preview.yml` workflow
71+
72+
3. **Workflow steps:**
73+
- Checkout code with submodules
74+
- Set up pnpm and Node.js
75+
- Install dependencies (cached)
76+
- Build Next.js application
77+
- Deploy to Vercel preview
78+
- Comment on PR with preview URL
79+
80+
4. **Preview ready** 🚀
81+
82+
## 🛠 Configuration
83+
84+
### Vercel Configuration
85+
86+
Edit `vercel.json` to customize deployment settings:
87+
88+
```json
89+
{
90+
"version": 2,
91+
"builds": [
92+
{
93+
"src": "package.json",
94+
"use": "@vercel/next"
95+
}
96+
],
97+
"routes": [
98+
{
99+
"src": "/(.*)",
100+
"dest": "/"
101+
}
102+
],
103+
"env": {
104+
"MISTRAL_API_KEY": "@mistral_api_key",
105+
"NEXT_PUBLIC_BASE_URL": "@next_public_base_url"
106+
},
107+
"public": true
108+
}
109+
```
110+
111+
### Environment Variables
112+
113+
Set these in your Vercel project settings:
114+
115+
| Variable | Description | Default |
116+
|----------|-------------|---------|
117+
| `MISTRAL_API_KEY` | Mistral AI API key | None |
118+
| `NEXT_PUBLIC_BASE_URL` | Production domain | None |
119+
120+
## 🔧 Troubleshooting
121+
122+
### Common Issues
123+
124+
**1. Deployment fails with "Invalid token"**
125+
- Ensure `VERCEL_TOKEN` is correctly set in GitHub Secrets
126+
- Verify the token has proper permissions in Vercel
127+
128+
**2. Build fails with missing dependencies**
129+
- Run `pnpm install` locally to verify
130+
- Check `pnpm-lock.yaml` for consistency
131+
132+
**3. Preview URL not posted to PR**
133+
- Ensure GitHub Actions has write permissions
134+
- Check the workflow logs for errors
135+
136+
**4. Deployment stuck or timing out**
137+
- Check GitHub Actions logs for specific errors
138+
- Verify Vercel project exists and ID is correct
139+
140+
## 📊 Monitoring
141+
142+
- **GitHub Actions**: Monitor workflow runs
143+
- **Vercel Dashboard**: View deployment status and logs
144+
- **Preview Comments**: Check PR for preview URLs
145+
146+
## 🎉 Best Practices
147+
148+
1. **Use descriptive commit messages** for easier deployment tracking
149+
2. **Test locally** before pushing to main
150+
3. **Use pull requests** for all changes to trigger preview deployments
151+
4. **Monitor deployments** in both GitHub and Vercel
152+
5. **Rotate secrets** regularly for security
153+
154+
## 🔒 Security
155+
156+
- Never commit secrets to code
157+
- Use GitHub Secrets for all sensitive information
158+
- Rotate tokens regularly
159+
- Limit token permissions to what's necessary
160+
161+
---
162+
163+
**Need help?** Check the [Vercel documentation](https://vercel.com/docs) or [GitHub Actions documentation](https://docs.github.com/en/actions) for more details.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Deploy Preview to Vercel
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: preview-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
env:
12+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
13+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
14+
NODE_VERSION: 18
15+
PNPM_VERSION: 9
16+
17+
jobs:
18+
deploy-preview:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
fetch-depth: 0
26+
27+
- name: Set up pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: ${{ env.PNPM_VERSION }}
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: ${{ env.NODE_VERSION }}
36+
cache: 'pnpm'
37+
cache-dependency-path: '**/pnpm-lock.yaml'
38+
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
42+
- name: Cache Next.js build
43+
uses: actions/cache@v3
44+
with:
45+
path: |
46+
.next/cache
47+
node_modules
48+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.ts', '**/*.tsx', '**/*.js', '**/*.json') }}
49+
restore-keys: |
50+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
51+
52+
- name: Build application
53+
run: pnpm build
54+
env:
55+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
56+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
57+
58+
- name: Install Vercel CLI
59+
run: npm install -g vercel@latest
60+
61+
- name: Configure Vercel
62+
run: |
63+
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
64+
vercel link --yes --token=${{ secrets.VERCEL_TOKEN }}
65+
66+
- name: Build with Vercel
67+
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
68+
env:
69+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
70+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
71+
72+
- name: Deploy Preview to Vercel
73+
id: deploy
74+
run: |
75+
DEPLOYMENT_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} | grep -o 'https://[^ ]*')
76+
echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
77+
env:
78+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
79+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
80+
81+
- name: Comment on PR with preview URL
82+
if: github.event_name == 'pull_request'
83+
uses: actions/github-script@v6
84+
with:
85+
script: |
86+
const deploymentUrl = '${{ steps.deploy.outputs.deployment_url }}';
87+
const comment = `🚀 **Preview Deployment Ready!** 🎉
88+
89+
🔗 **Preview URL:** ${deploymentUrl}
90+
91+
✨ This preview will be automatically updated with new changes to this PR.
92+
93+
💡 **Note:** Preview deployments are temporary and will be deleted when the PR is closed.`;
94+
95+
// Check if comment already exists
96+
const { data: comments } = await github.rest.issues.listComments({
97+
owner: context.repo.owner,
98+
repo: context.repo.repo,
99+
issue_number: context.issue.number
100+
});
101+
102+
const existingComment = comments.find(c =>
103+
c.user.login === 'github-actions[bot]' &&
104+
c.body.includes('Preview Deployment Ready')
105+
);
106+
107+
if (existingComment) {
108+
await github.rest.issues.updateComment({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
comment_id: existingComment.id,
112+
body: comment
113+
});
114+
} else {
115+
await github.rest.issues.createComment({
116+
owner: context.repo.owner,
117+
repo: context.repo.repo,
118+
issue_number: context.issue.number,
119+
body: comment
120+
});
121+
}
122+
123+
- name: Clean up
124+
if: always()
125+
run: |
126+
rm -rf node_modules/.cache
127+
rm -rf .next/cache
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Deploy to Vercel
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
concurrency:
10+
group: deploy-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
15+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
16+
NODE_VERSION: 18
17+
PNPM_VERSION: 9
18+
19+
jobs:
20+
deploy:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
submodules: true
27+
fetch-depth: 0
28+
29+
- name: Set up pnpm
30+
uses: pnpm/action-setup@v4
31+
with:
32+
version: ${{ env.PNPM_VERSION }}
33+
34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: ${{ env.NODE_VERSION }}
38+
cache: 'pnpm'
39+
cache-dependency-path: '**/pnpm-lock.yaml'
40+
41+
- name: Install dependencies
42+
run: pnpm install --frozen-lockfile
43+
44+
- name: Cache Next.js build
45+
uses: actions/cache@v3
46+
with:
47+
path: |
48+
.next/cache
49+
node_modules
50+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.ts', '**/*.tsx', '**/*.js', '**/*.json') }}
51+
restore-keys: |
52+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
53+
54+
- name: Build application
55+
run: pnpm build
56+
env:
57+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
58+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
59+
60+
- name: Install Vercel CLI
61+
run: npm install -g vercel@latest
62+
63+
- name: Configure Vercel
64+
run: |
65+
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
66+
vercel link --yes --token=${{ secrets.VERCEL_TOKEN }}
67+
68+
- name: Build with Vercel
69+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
70+
env:
71+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
72+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
73+
74+
- name: Deploy to Vercel
75+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
76+
env:
77+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
78+
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
79+
80+
- name: Verify deployment
81+
run: |
82+
echo "✅ Deployment completed successfully!"
83+
echo "📍 Deployment URL will be available in Vercel dashboard"
84+
echo "🔗 Check GitHub Actions for deployment details"
85+
86+
- name: Clean up
87+
if: always()
88+
run: |
89+
rm -rf node_modules/.cache
90+
rm -rf .next/cache

0 commit comments

Comments
 (0)