Welcome to the Hackerspace Mumbai website development team! This guide will help you set up your local development environment and understand our deployment workflows.
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- pnpm (recommended package manager)
- Git (for version control)
- Netlify CLI (for deployment testing)
# Install Node.js (using nvm - recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 18
nvm use 18
# Install pnpm
npm install -g pnpm
# Install Netlify CLI
npm install -g netlify-cli
# Verify installations
node --version
pnpm --version
netlify --versiongit clone https://github.com/HackerspaceMumbai/blog.git
cd blogpnpm installCreate a local environment file for development:
# Copy the example environment file
cp .env.example .env
# Edit the .env file with your values
# Note: This file should NOT be committed to git# Start the development server
pnpm dev
# Open http://localhost:4321 in your browser
# You should see the Hackerspace Mumbai websiteWe have two main deployment environments:
- CI/CD (GitHub Actions): Automated deployments for pull requests and production
- Local Development: Manual deployments for testing and development
You'll need access to our Netlify account to set up local deployment. Contact a maintainer to:
-
Get added to the Netlify team for the Hackerspace Mumbai site
-
Generate a personal access token:
- Go to Netlify User Settings > Applications
- Click "New access token"
- Name it "Local Development - [Your Name]"
- Copy the generated token
-
Get the site ID:
- Go to the Netlify dashboard
- Select the Hackerspace Mumbai site
- Navigate to Site Settings > General
- Copy the "Site ID" from Site Information
Add your Netlify credentials to your local environment:
# Option 1: Add to .env file (recommended)
echo "NETLIFY_AUTH_TOKEN=your_token_here" >> .env
echo "NETLIFY_SITE_ID=your_site_id_here" >> .env
# Option 2: Export directly in your shell
export NETLIFY_AUTH_TOKEN="your_token_here"
export NETLIFY_SITE_ID="your_site_id_here"
# Add to your shell profile for persistence (.bashrc, .zshrc, etc.)
echo 'export NETLIFY_AUTH_TOKEN="your_token_here"' >> ~/.bashrc
echo 'export NETLIFY_SITE_ID="your_site_id_here"' >> ~/.bashrc# Test Netlify authentication
netlify status
# You should see output like:
# ──────────────────────────────────────────────
# Current Netlify User
# ──────────────────────────────────────────────
# Name: Your Name
# Email: your.email@example.com# Build the site
pnpm build
# Deploy a preview (safe for testing)
pnpm deploy:preview
# You'll get a preview URL like:
# https://deploy-preview-123--your-site.netlify.app# 1. Pull latest changes
git pull origin main
# 2. Install any new dependencies
pnpm install
# 3. Start development server
pnpm dev
# 4. Make your changes
# 5. Test locally at http://localhost:4321# Run tests
pnpm test --run
# Run accessibility tests
pnpm test:a11y --run
# Run blog image tests (critical for blog changes)
pnpm test:blog-images --run
# Build and preview production version
pnpm build
pnpm preview# Test deployment locally before pushing
pnpm build
pnpm deploy:preview
# Check the preview URL to ensure everything works
# Only then push your changesWhen it runs:
- Automatically on pull requests (preview deployment)
- Automatically on main branch pushes (production deployment)
How it works:
- Uses repository secrets for authentication
- Runs in a clean, isolated environment
- Uses CI-optimized commands with
--jsonoutput - Includes automated health checks and verification
Key differences:
- Non-interactive (no prompts)
- Uses structured JSON output for parsing
- Includes comprehensive error handling
- Runs post-deployment verification
Example CI commands:
# CI uses these commands (you don't run these locally)
pnpm deploy:preview:ci # Outputs JSON for parsing
pnpm deploy:prod:ci # Production with JSON outputWhen to use:
- Testing changes before creating a pull request
- Debugging deployment issues
- Quick iteration on deployment-related changes
How it works:
- Uses your personal Netlify credentials
- Interactive (can prompt for confirmation)
- Uses human-readable output
- Manual verification of results
Key differences:
- Interactive prompts allowed
- Human-readable output
- Manual health checking
- Personal authentication tokens
Example local commands:
# Local development uses these commands
pnpm deploy:preview # Human-readable output
pnpm deploy:prod # Production deployment (be careful!)| Scenario | Method | Command |
|---|---|---|
| Testing PR changes | CI/CD | Automatic on PR creation |
| Quick local testing | Local | pnpm deploy:preview |
| Production release | CI/CD | Automatic on main branch |
| Debugging deployment | Local | pnpm deploy:preview |
| Emergency hotfix | Local | pnpm deploy:prod (with caution) |
# 1. Create new post directory
mkdir src/content/posts/my-new-post
# 2. Add cover image
cp cover-image.png src/content/posts/my-new-post/cover.png
# 3. Create content file
touch src/content/posts/my-new-post/index.mdx
# 4. Test blog image display
pnpm test:blog-images --run
# 5. Preview locally
pnpm dev# 1. Make your changes to components
# 2. Test the changes
pnpm dev
# 3. Run relevant tests
pnpm test --run
# 4. Test accessibility
pnpm test:a11y --run
# 5. Build and test production version
pnpm build
pnpm preview# 1. Make changes to deployment scripts
# 2. Test locally first
pnpm build
pnpm deploy:preview
# 3. Verify the preview works
# 4. Create PR for review
# 5. CI will test the changes automatically# Install pnpm globally
npm install -g pnpm# Check your environment variables
echo $NETLIFY_AUTH_TOKEN
echo $NETLIFY_SITE_ID
# Re-authenticate if needed
netlify login# Verify your site ID is correct
netlify sites:list
# Check if you have access to the site
netlify api getSite --data='{"site_id":"YOUR_SITE_ID"}'# Make sure you're using the --run flag
pnpm test --run
# For specific test files
pnpm test path/to/test.js --run
# Clear test cache if needed
rm -rf node_modules/.vitest- Check the troubleshooting guide: docs/deployment-troubleshooting.md
- Review project documentation: README.md and CONTRIBUTING.md
- Ask in team chat: Mention deployment issues in our communication channel
- Create a GitHub issue: For persistent problems or bugs
- Never commit credentials: Keep
.envfiles out of git - Use personal tokens: Don't share authentication tokens
- Rotate tokens regularly: Generate new tokens periodically
- Limit token scope: Use tokens with minimal required permissions
- Test locally first: Always test changes locally before pushing
- Run tests: Use
--runflag to ensure tests complete - Check accessibility: Run a11y tests for UI changes
- Verify blog images: Run blog image tests for content changes
- Use preview deployments: Test with
deploy:previewbefore production - Verify URLs: Check preview URLs work correctly
- Monitor CI/CD: Watch GitHub Actions for deployment status
- Document changes: Update docs when changing deployment process
After completing this setup:
- Read the contributing guide: CONTRIBUTING.md
- Explore the codebase: Familiarize yourself with the project structure
- Make a test change: Try creating a small blog post or component update
- Join team communications: Get added to relevant chat channels
- Review open issues: Look for "good first issue" labels on GitHub
Welcome to the team! 🚀