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
1,134 changes: 1,134 additions & 0 deletions .ai/hosting-analysis.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Supabase Configuration
# Get these values by running: supabase start
PUBLIC_SUPABASE_URL=http://localhost:54321
PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
PUBLIC_SUPABASE_URL=your_supabase_project_url
PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key

# OpenRouter AI Configuration
OPENROUTER_API_KEY=your-openrouter-api-key-here
# OpenRouter AI Service
OPENROUTER_API_KEY=your_openrouter_api_key

# Application Configuration
NODE_ENV=development
# Optional: Testing & Development
# NODE_ENV=development
# DISABLE_RATE_LIMIT=false
117 changes: 117 additions & 0 deletions .github/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Deployment na Netlify

## ⚠️ Ważne: Konfiguracja projektu na Netlify

Jeśli już masz utworzony projekt na Netlify i widzisz błąd 404, **MUSISZ** sprawdzić i poprawić ustawienia:

### Poprawka dla istniejącego projektu

1. Wejdź w **Site settings** > **Build & deploy** > **Build settings**
2. Znajdź pole **Publish directory**
3. **POZOSTAW JE PUSTE** lub usuń wartość "dist"
- Adapter Astro Netlify automatycznie wykryje właściwą strukturę
- Ręczne ustawienie "dist" powoduje błąd 404!
4. Kliknij **Save**
5. Wykonaj **Clear cache and deploy site** w zakładce **Deploys**

### 1. Konfiguracja nowego projektu Netlify

1. Zaloguj się do [Netlify](https://app.netlify.com/)
2. Utwórz nowy projekt
3. Znajdź **Site ID** w ustawieniach projektu (Settings > General > Site details)
4. Wygeneruj **Personal Access Token** w ustawieniach użytkownika (User settings > Applications > Personal access tokens)
5. **Ważne**: W Build settings **NIE ustawiaj** Publish directory (pozostaw puste)

### 2. Konfiguracja GitHub Secrets

Dodaj następujące sekrety w ustawieniach repozytorium GitHub:
(Settings > Secrets and variables > Actions > New repository secret)

#### Wymagane sekrety:

- `PUBLIC_SUPABASE_URL` - URL twojego projektu Supabase
- `PUBLIC_SUPABASE_ANON_KEY` - Klucz publiczny (anon) z Supabase
- `OPENROUTER_API_KEY` - Klucz API do OpenRouter.ai
- `NETLIFY_SITE_ID` - ID projektu Netlify
- `NETLIFY_AUTH_TOKEN` - Personal Access Token z Netlify

#### Opcjonalne sekrety dla codecov:

- `CODECOV_TOKEN` - Token do przesyłania raportów coverage (jeśli używasz)

### 3. Zmienne środowiskowe w Netlify

Dodaj również zmienne środowiskowe w panelu Netlify:
(Site settings > Environment variables)

- `PUBLIC_SUPABASE_URL`
- `PUBLIC_SUPABASE_ANON_KEY`
- `OPENROUTER_API_KEY`

### 4. Deployment

Po skonfigurowaniu sekretów, każdy push do brancha `main` automatycznie:
1. Uruchomi linting
2. Wykona testy jednostkowe
3. Zbuduje projekt
4. Wdroży na Netlify

## Lokalne testowanie buildu

Aby przetestować build lokalnie przed wdrożeniem:

```bash
npm run build
npm run preview
```

## Struktura CI/CD

Workflow `master.yml` składa się z następujących kroków:

1. **Lint** - sprawdzenie jakości kodu
2. **Unit Tests** - testy jednostkowe z coverage
3. **Build** - budowanie aplikacji
4. **Deploy** - wdrożenie na Netlify
5. **Status Notification** - powiadomienie o statusie deployu

## Troubleshooting

### ❌ Błąd 404 "Not Found" na stronie

**Przyczyna**: Najczęściej to problem z ustawieniem "Publish directory" w Netlify.

**Rozwiązanie**:
1. W panelu Netlify: **Site settings** > **Build & deploy** > **Build settings**
2. Znajdź **Publish directory** i **usuń wartość** (pozostaw puste)
3. Kliknij **Save**
4. W zakładce **Deploys** kliknij **Clear cache and deploy site**

### Build fails on Netlify

Sprawdź:
- Czy wszystkie zmienne środowiskowe są poprawnie ustawione w Netlify
- Czy Node.js version (22.14.0) jest wspierana
- Logi buildu w panelu Netlify

### Deployment fails in GitHub Actions

Sprawdź:
- Czy wszystkie sekrety są dodane w GitHub
- Czy `NETLIFY_SITE_ID` i `NETLIFY_AUTH_TOKEN` są poprawne
- Logi workflow w GitHub Actions

### Environment variables missing

Upewnij się, że:
- Zmienne są dodane zarówno w GitHub Secrets (dla CI/CD)
- Zmienne są dodane w Netlify (dla runtime)
- Zmienne zaczynające się od `PUBLIC_` są dostępne w kodzie klienckim

### Funkcje SSR nie działają

Upewnij się, że:
- Plik `public/_redirects` istnieje i przekierowuje do `/.netlify/functions/ssr`
- W `netlify.toml` NIE MA ustawionego `publish` directory
- Build command to `npm run build`

146 changes: 146 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Master CI/CD

on:
push:
branches:
- main

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
env:
PUBLIC_SUPABASE_URL: ${{ secrets.PUBLIC_SUPABASE_URL }}
PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PUBLIC_SUPABASE_ANON_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

unit-test:
name: Unit Tests
runs-on: ubuntu-latest
needs: lint
env:
PUBLIC_SUPABASE_URL: ${{ secrets.PUBLIC_SUPABASE_URL }}
PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PUBLIC_SUPABASE_ANON_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run unit tests with coverage
run: npm run test:coverage

- name: Upload unit test coverage
uses: codecov/codecov-action@v5
with:
files: ./coverage/coverage-final.json
flags: unit
name: unit-tests
fail_ci_if_error: false

build:
name: Build Application
runs-on: ubuntu-latest
needs: [lint, unit-test]
env:
PUBLIC_SUPABASE_URL: ${{ secrets.PUBLIC_SUPABASE_URL }}
PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PUBLIC_SUPABASE_ANON_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
retention-days: 1

deploy:
name: Deploy to Netlify
runs-on: ubuntu-latest
needs: build
env:
PUBLIC_SUPABASE_URL: ${{ secrets.PUBLIC_SUPABASE_URL }}
PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PUBLIC_SUPABASE_ANON_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Download build artifacts
uses: actions/download-artifact@v5
with:
name: dist
path: dist

- name: Deploy to Netlify
uses: netlify/actions/cli@master
with:
args: deploy --prod --dir=dist
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

status-notification:
name: Deployment Status
runs-on: ubuntu-latest
needs: [lint, unit-test, build, deploy]
if: always()
steps:
- name: Check deployment status
run: |
if [ "${{ needs.deploy.result }}" == "success" ]; then
echo "✅ Deployment successful!"
else
echo "❌ Deployment failed!"
exit 1
fi

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build output
dist/
.netlify/
# generated types
.astro/

Expand Down
1 change: 1 addition & 0 deletions .netlify/build/_@astrojs-ssr-adapter.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@astrojs/netlify/ssr-function.js';
Loading