Skip to content

Commit

Permalink
Updated readme (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakbar-deriv authored Jan 13, 2025
1 parent 8025167 commit 28eb0f3
Showing 1 changed file with 32 additions and 103 deletions.
135 changes: 32 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Personal Portfolio Website

A modern, responsive portfolio website built with React and Vite, featuring automated deployments to GitHub Pages.
A modern, responsive portfolio website built with React and Vite.

## Project Structure

Expand Down Expand Up @@ -40,6 +40,7 @@ myself-react-app/
## Installation

1. Clone the repository:

```bash
git clone https://github.com/yourusername/myself-react-app.git
cd myself-react-app
Expand All @@ -55,6 +56,7 @@ myself-react-app/
The project supports three environments: Development, Staging, and Production. Each environment has its own configuration and can be run locally for testing.

### Development Mode

Development mode is optimized for local development with hot reloading and debugging features.

```bash
Expand All @@ -69,7 +71,6 @@ http://localhost:5173/
- Source maps
- Debug logging enabled
- Mock API enabled
- No base path prefix

# Environment variables (.env.development)
VITE_APP_ENV=development
Expand All @@ -80,6 +81,7 @@ VITE_APP_ENABLE_DEBUG=true
```

### Staging Mode

Staging mode mimics production but with additional debugging capabilities.

```bash
Expand All @@ -90,14 +92,13 @@ npm run build:staging
npm run preview:staging

# Access the app at
http://localhost:4173/myself-react-app-staging/
http://localhost:4173/

# Features
- Production-like build
- Source maps included
- Debug logging enabled
- Real API endpoints
- Staging-specific base path

# Environment variables (.env.staging)
VITE_APP_ENV=staging
Expand All @@ -108,6 +109,7 @@ VITE_APP_ENABLE_DEBUG=true
```

### Production Mode

Production mode is fully optimized for deployment.

```bash
Expand All @@ -118,14 +120,13 @@ npm run build
npm run preview

# Access the app at
http://localhost:4173/myself-react-app/
http://localhost:4173/

# Features
- Minified build
- No source maps
- Debug logging disabled
- Real API endpoints
- Production base path
- Optimized chunk splitting

# Environment variables (.env.production)
Expand All @@ -139,16 +140,19 @@ VITE_APP_ENABLE_DEBUG=false
### Build Output Comparison

Development:

- No build output (serves directly from source)
- Instant updates via HMR

Staging:

- JS: ~144.5 KB (gzip: ~47 KB)
- CSS: ~1.75 KB (gzip: ~0.75 KB)
- Includes source maps
- Separate vendor chunks

Production:

- JS: ~144.4 KB (gzip: ~46.9 KB)
- CSS: ~1.75 KB (gzip: ~0.75 KB)
- No source maps
Expand All @@ -158,6 +162,7 @@ Production:
## Available Scripts

- **Development**:

```bash
npm run dev # Start development server
npm run test # Run tests once
Expand All @@ -166,12 +171,14 @@ Production:
```

- **Staging**:

```bash
npm run build:staging # Build for staging
npm run preview:staging # Preview staging build
```

- **Production**:

```bash
npm run build # Build for production
npm run preview # Preview production build
Expand All @@ -189,138 +196,60 @@ Production:
The project uses Vitest and React Testing Library for testing. Tests are located alongside their components with the `.test.jsx` extension.

To run tests:

```bash
npm test
```

For test coverage:

```bash
npm run test:coverage
```

## Deployment

The project is configured for automated deployment to GitHub Pages:
The project uses GitHub Actions for automated deployments:

- **Production Deployment**: Automatically triggered when changes are merged to the main branch
- **Preview Deployment**: Automatically created for pull requests

## GitHub Workflow Configuration
### Environment Setup

### 1. Enable GitHub Pages
1. Go to repository Settings > Pages
2. Under "Build and deployment":
- Source: Select "GitHub Actions"
- This enables GitHub Pages deployment through workflows
1. Configure Repository Permissions

### 2. Configure Repository Permissions
1. Go to Settings > Actions > General
2. Under "Workflow permissions":
- Select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"
3. Under "Required approvals":
- Set the number of approvals required for production deployments
- Go to Settings > Actions > General
- Under "Workflow permissions":
- Select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"

### 3. Set Up Environment Secrets
1. Go to Settings > Secrets and variables > Actions
2. Click "New repository secret"
3. Add the following secrets:
2. Set Up Environment Secrets

Production Environment:
```
PROD_BASE_URL=https://yourdomain.com
PROD_API_URL=https://api.yourdomain.com/api
PROD_GA_ID=UA-PRODUCTION-ID
```
- Go to Settings > Secrets and variables > Actions
- Add environment-specific secrets for your deployment

Staging Environment:
```
STAGING_BASE_URL=https://staging.yourdomain.com
STAGING_API_URL=https://api-staging.yourdomain.com/api
STAGING_GA_ID=UA-STAGING-ID
```

### 4. Configure Environments
1. Go to Settings > Environments
2. Create two environments:
- "github-pages" (required for production)
- "preview-{PR_NUMBER}" (for pull request previews)

3. For "github-pages" environment:
- Click "Configure environment"
- Add deployment branch rules:
* Select "Protected branches"
* Add "main" as protected branch
- Add required reviewers if needed
- Add environment-specific secrets

4. For "preview-{PR_NUMBER}" environment:
- Configure deployment rules:
* Allow all branches (for PR previews)
- No approval required (for faster preview deployments)

### 5. Branch Protection Rules
1. Go to Settings > Branches
2. Click "Add branch protection rule"
3. For the "main" branch:
- Require pull request reviews
- Require status checks to pass
- Require conversation resolution
- Include administrators in restrictions

### 6. Verify Workflow Files
Ensure these files exist in your repository:
```
.github/workflows/
├── deploy-production.yml # For main branch deployments
└── deploy-preview.yml # For PR preview deployments
```

### 7. Additional Settings (Optional)
1. Configure Issue Templates:
- Go to Settings > General > Features
- Enable "Issues"
- Set up issue templates

2. Pull Request Template:
- Create `.github/pull_request_template.md`
- Define standard PR format

3. Configure Dependency Updates:
- Enable Dependabot alerts
- Set up automatic security updates

### Troubleshooting Common Issues

1. Deployment Failures:
- Verify workflow permissions
- Check if secrets are properly set
- Ensure environment names match exactly

2. Preview Deployments Not Working:
- Check if PR comes from a fork
- Verify preview environment exists
- Check workflow logs for errors

3. Production Deployment Issues:
- Verify branch protection rules
- Check if required reviews are completed
- Ensure github-pages environment is configured
3. Configure Environments
- Set up separate environments for production and staging
- Configure environment-specific variables and secrets
- Set up required reviewers and deployment rules as needed

## Development

1. Create a new branch for your feature:

```bash
git checkout -b feature/your-feature-name
```

2. Make your changes and commit them:

```bash
git add .
git commit -m "Add your feature"
```

3. Push to your branch:

```bash
git push origin feature/your-feature-name
```
Expand Down

0 comments on commit 28eb0f3

Please sign in to comment.