GitHub Best Practices

Professional best practices for GitHub project management, complementary to the Git basics already covered

GitHub Best Practices

GitHub is a collaborative platform that, when used correctly, can significantly improve the quality and efficiency of your development projects. This section complements the Git basics already covered by focusing on professional and collaborative aspects.

Professional Repository Creation

Note:

For basic Git commands (init, add, commit), check the Git Commands section.

GitHub Specific Configuration

Once your local repository is created with basic Git commands, here are GitHub-specific elements:

Repository Settings

  • Name: Descriptive and consistent with conventions
  • Description: Clear, concise, with keywords
  • Visibility: Private/Public according to context
  • Features: Issues, Wiki, Projects enabled

Professional Repository Structure

my-project/ ├── .github/ # GitHub workflows and templates │ ├── workflows/ # CI/CD Actions │ │ ├── ci.yml # Tests and build │ │ └── deploy.yml # Deployment │ ├── ISSUE_TEMPLATE/ # Issue templates │ ├── PULL_REQUEST_TEMPLATE.md │ └── dependabot.yml # Dependencies configuration ├── docs/ # Technical documentation │ ├── api/ # API documentation │ ├── deployment/ # Deployment guides │ └── development/ # Development guides ├── src/ # Source code ├── tests/ # Automated tests ├── .gitignore # Git exclusions ├── .dockerignore # Docker exclusions ├── README.md # Main documentation ├── CONTRIBUTING.md # Contribution guide ├── LICENSE # Project license ├── CHANGELOG.md # Version history └── package.json # Metadata and dependencies

GitHub Actions and CI/CD

Basic Workflow

GitHub Actions automate testing, building, and deployment processes.

Basic CI Workflow

name: CI

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v3
    
    - name: Setup Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '18'
        cache: 'npm'
    
    - name: Install dependencies
      run: npm ci
    
    - name: Run tests
      run: npm test
    
    - name: Build project
      run: npm run build

## Issues and Projects Management

### Issue Templates

Issue templates standardize bug reports and feature requests.

#### Bug Report Template

---
name: Bug report
about: Report a problem to help us improve
title: '[BUG] '
labels: 'bug'
---

## Bug Description
Clear and concise description of the problem.

## Steps to Reproduce
1. Go to '...'
2. Click on '....'
3. Scroll to '....'
4. See error

## Expected Behavior
Description of what should happen.

## Environment
- OS: [e.g. Windows 11]
- Browser: [e.g. Chrome 91]
- Version: [e.g. 1.2.3]

## Security and Best Practices

### Secrets Protection

#### Environment Variables
```bash
# .env.example (versioned)
DATABASE_URL=postgresql://localhost:5432/myapp
API_KEY=your-api-key-here

# .env (NOT versioned, in .gitignore)
DATABASE_URL=postgresql://prod-server:5432/myapp
API_KEY=real-production-api-key

#### GitHub Secrets
Configure sensitive data in repository settings:
- `DATABASE_URL`: Production database URL
- `API_KEYS`: Third-party API keys
- `DEPLOY_TOKEN`: Deployment token

## Metrics and Monitoring

### GitHub Badges

![Build Status](https://github.com/user/repo/workflows/CI/badge.svg)
![Coverage](https://codecov.io/gh/user/repo/branch/main/graph/badge.svg)
![License](https://img.shields.io/github/license/user/repo)
![Contributors](https://img.shields.io/github/contributors/user/repo)

### Important Metrics to Track
- Code coverage (>80%)
- Number of production bugs
- Issue resolution time
- Team velocity

---

*This page is currently available in French only. English translation coming soon.*

For the complete content in French, please visit: [GitHub et Bonnes Pratiques](/fr/docs/project-management/github-best-practices)