Deployment

This project deploys the React app to Vercel (live site). At build time, scripts/fetchProjects.js fetches GitHub data and writes static artifacts to public/ before the React build starts. The generated API docs are published separately to GitHub Pages via the gh-pages branch.

Contents

Deployment targets

Target URL Trigger Branch
Vercel (live site) carloskeglevich.vercel.app Push to main main
GitHub Pages (API docs) https://keglev.github.io/my-portfolio/ Workflow dispatch gh-pages

Environment variables

Set these in the Vercel dashboard under Project → Settings → Environment Variables, targeting the Build step for both Production and Preview environments.

Variable Required Description
GH_PROJECTS_TOKEN Yes GitHub PAT. Use public_repo scope for public repos, repo for private
DEEPL_API_KEY No If set, translates project summaries to German via DeepL
DEBUG_FETCH No Set to 1 to emit extra debug logs. Disable in production

Deploying to Vercel

Vercel runs prebuild automatically before build, so no manual intervention is required after the initial setup.

  1. Connect the GitHub repository to a Vercel project (first-time setup only).
  2. Set GH_PROJECTS_TOKEN in the Vercel dashboard, targeting the Build step.
  3. Optionally set DEEPL_API_KEY in the same location.
  4. Push to main — Vercel detects the push and starts a new deployment.
  5. Vercel runs npm run prebuild (scripts/fetchProjects.js), then npm run build (react-scripts build).
  6. Vercel publishes the output from build/ to the live URL.
flowchart LR
    A[Push to main] --> B[Vercel build trigger]
    B --> C[npm run prebuild\nfetchProjects.js]
    C --> D[npm run build\nreact-scripts build]
    D --> E[Publish build/\nto Vercel CDN]

Running locally

Use these steps to preview generated artifacts before committing or deploying.

  1. Create a .env.local file at the repository root (gitignored by CRA):
GH_PROJECTS_TOKEN=your_github_pat_here
DEEPL_API_KEY=optional_deepl_key
  1. Optionally enable debug output in the current shell only:
$env:DEBUG_FETCH = '1'
  1. Run the fetch script to generate artifacts:
node .\scripts\fetchProjects.js
  1. Run the React build:
npm run build
  1. Optionally prepare and deploy a prebuilt Vercel output:
Remove-Item -Recurse -Force .vercel\output -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force .vercel\output\static | Out-Null
Copy-Item -Path build\* -Destination .vercel\output\static -Recurse -Force
Copy-Item -Path public\projects.json -Destination .vercel\output\static\projects.json -Force
Copy-Item -Path public\projects_media -Destination .vercel\output\static\projects_media -Recurse -Force

@"
{
  "version": 3,
  "routes": [
    { "handle": "filesystem" },
    { "src": "/(.*)", "dest": "/index.html" }
  ]
}
"@ | Out-File -FilePath .vercel\output\config.json -Encoding utf8

npx vercel --prebuilt . --token $env:VERCEL_TOKEN --yes

Build artifacts

The files public/projects.json and public/projects_media/ are generated by scripts/fetchProjects.js and are intentionally excluded from version control. CI regenerates them on every build. If these files appear committed in the repository, remove them — committing them risks leaking tokens or including large binary blobs.

Security

Troubleshooting

References