Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GitHub Models API - Free tier (included with GitHub Copilot Pro!)
# Get token: https://github.com/settings/tokens
# Select: repo, read:user scopes

VITE_GITHUB_TOKEN=your_github_token_here

32 changes: 18 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,53 @@ name: Deploy to GitHub Pages

on:
push:
branches: ["main"] # Replace with your default branch name if different
workflow_dispatch:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install
run: npm ci

- name: Build
- name: Build app
run: npm run build
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}

- name: Setup Pages
uses: actions/configure-pages@v4
VITE_GITHUB_TOKEN: ${{ secrets.VITE_GITHUB_TOKEN }}

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
path: dist

deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ node_modules
dist
dist-ssr
*.local
.env
.env.local
.env.*.local

# Editor directories and files
.vscode/*
Expand Down
9 changes: 5 additions & 4 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useState } from 'react';
import Header from './components/Header';
import ChecklistResult from './components/ChecklistResult';
import { generateVisaChecklist } from './services/geminiService';
import { generateVisaChecklist } from './services/aiService';
import { COUNTRIES } from './constants';
import { VisaChecklist, VisaType } from './types';

Expand Down Expand Up @@ -34,9 +34,10 @@ const App: React.FC = () => {
try {
const result = await generateVisaChecklist(fromCountry, toCountry, visaType);
setChecklist(result);
} catch (err: any) {
console.error(err);
setError("Unable to generate checklist. Please try again later.");
} catch (err) {
const errorMessage = err instanceof Error ? err.message : "Unknown error occurred";
setError(errorMessage);
console.error("Visa checklist error:", err);
} finally {
setLoading(false);
}
Expand Down
128 changes: 128 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Deployment Guide - GitHub Pages

Complete guide to deploying the Visa Checklist Generator on GitHub Pages using GitHub Actions.

## Prerequisites

- GitHub account with repository access
- GitHub Copilot Pro subscription
- GitHub token configured (see [GITHUB_MODELS_SETUP.md](GITHUB_MODELS_SETUP.md))

## Local Setup

For local development setup, see [GITHUB_MODELS_SETUP.md](GITHUB_MODELS_SETUP.md).

For quick reference:
```bash
npm install
npm run dev
```

## Production Deployment

### Step 1: Add GitHub Secret

1. Go to your repository: https://github.com/krushideep/visacraft
2. Settings → Secrets and variables → Actions
3. Click "New repository secret"
4. Name: `VITE_GITHUB_TOKEN`
5. Value: Paste your GitHub token (see [GITHUB_MODELS_SETUP.md](GITHUB_MODELS_SETUP.md#1-generate-github-personal-access-token))
6. Click "Add secret"

⚠️ **Important:** Never commit `.env.local` to git - use secrets instead!

### Step 2: Enable GitHub Pages

1. Go to Settings → Pages
2. Source: "Deploy from a branch"
3. Branch: `main` → `/ (root)`
4. Click "Save"

### Step 3: Deploy

1. Commit and push changes:
```bash
git add .
git commit -m "Setup GitHub Pages deployment"
git push origin main
```

2. Monitor deployment:
- Go to Actions tab
- Watch the workflow run
- After success (~2 min), site is live

### Step 4: Access Live Site

🌐 **Your app:** https://krushideep.github.io/visacraft

The workflow automatically rebuilds and deploys on every push to main.

## GitHub Actions Workflow

The workflow (`.github/workflows/deploy.yml`) automatically:
1. Checks out code on push to main
2. Installs Node dependencies
3. Passes `VITE_GITHUB_TOKEN` from GitHub Secrets
4. Builds the Vite app (creates `dist/` folder)
5. Uploads artifacts to GitHub Pages
6. Deploys to your live site

**Workflow file location:** `.github/workflows/deploy.yml`

## Troubleshooting

### Build fails: "GitHub token not configured"
1. Add `VITE_GITHUB_TOKEN` to GitHub Secrets (Settings → Secrets)
2. Rebuild by pushing new commit

### Workflow not running
1. Check branch is `main` (not `master`)
2. Verify workflow file exists: `.github/workflows/deploy.yml`
3. Go to Actions tab → click "Re-run jobs" to manually trigger

### For API & token errors
See [GITHUB_MODELS_SETUP.md](GITHUB_MODELS_SETUP.md#troubleshooting) for:
- "GitHub token not found"
- "Invalid token" / 401 errors
- Rate limiting (15 req/min)
- Token exposure risks

## Build & Deploy Commands

```bash
# Development
npm run dev

# Build for production
npm run build

# Preview production build locally
npm run preview
```

## Monitoring Deployments

1. **Actions Tab:** https://github.com/krushideep/visacraft/actions
- View all workflow runs
- Check logs for errors
- See deployment status

2. **GitHub Pages Settings:**
- Settings → Pages
- View deployment history

## Custom Domain (Optional)

To use a custom domain with GitHub Pages:
1. Settings → Pages → Custom domain
2. Enter your domain (e.g., `visacraft.example.com`)
3. Update DNS records (see GitHub docs)
4. Enable HTTPS

## Support & Resources

- **GitHub Pages Docs:** https://docs.github.com/pages
- **GitHub Actions Docs:** https://docs.github.com/actions
- **GitHub Models Setup:** [GITHUB_MODELS_SETUP.md](GITHUB_MODELS_SETUP.md)
- **Report Issues:** https://github.com/krushideep/visacraft/issues
113 changes: 113 additions & 0 deletions GITHUB_MODELS_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# GitHub Models API Setup

Complete guide to using GitHub Models API with your GitHub Copilot Pro account.

### 1. Generate GitHub Personal Access Token
1. Go to https://github.com/settings/tokens/new
2. Name it: "Visa Checklist GitHub Models"
3. Select scopes:
- ✅ `repo` (full control of private repositories)
- ✅ `read:user` (read user profile data)
4. Click "Generate token"
5. Copy the token

### 2. Add to Environment
Create `.env.local`:
```
VITE_GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
```

### 3. Install Dependencies
```bash
npm install
```

### 4. Run Locally
```bash
npm run dev
```

## Cost

**FREE!** 🎉
- GitHub Models API is FREE for GitHub Copilot Pro subscribers
- Rate limits: 15 requests per minute
- No credit card required
- Includes: Claude 3.5 Sonnet, GPT-4, Mistral, etc.

## Deployment to GitHub Pages

### With GitHub Actions

1. **Add token as secret:**
- Go to repo → Settings → Secrets and variables → Actions
- New secret: `VITE_GITHUB_TOKEN` = your token from step 1
- ⚠️ NEVER commit token to git - use secrets!

2. **Create `.github/workflows/deploy.yml`:**
```yaml
name: Deploy to GitHub Pages

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm ci
- run: npm run build
env:
VITE_GITHUB_TOKEN: ${{ secrets.VITE_GITHUB_TOKEN }}
- uses: actions/upload-pages-artifact@v2
with:
path: dist
- uses: actions/deploy-pages@v2
```

3. **Enable Pages:**
- Settings → Pages → Source: GitHub Actions

## Available Models via GitHub Models

- **Claude 3.5 Sonnet** ⭐ (Recommended - best accuracy)
- Claude 3 Opus
- GPT-4 Turbo
- Mistral Large
- Llama 2/3

## Features

✅ **Accurate results** - Claude 3.5 Sonnet for visa requirements
✅ **Free** - Included with Copilot Pro
✅ **Fast** - 1-3 second response time
✅ **Cached** - 7-day local caching
✅ **Secure** - Token only used at build time or on your machine
✅ **Scalable** - Deploy to GitHub Pages instantly

## Troubleshooting

### "Invalid token" error
- Check token hasn't expired
- Verify scopes: `repo` and `read:user` selected
- Generate new token if needed

### Rate limiting (15 req/min)
- Results are cached 7 days automatically
- Same country pairs won't hit API again

### Token exposure
- ⚠️ Never commit `.env.local` to git
- Already in `.gitignore` ✓
- Use GitHub Secrets for CI/CD

## Support

- GitHub Models: https://github.com/models
- Pricing: https://github.com/models#pricing
- Copilot Pro: https://github.com/copilot/pro
Loading
Loading