#GitHub

GitHub is the largest code hosting platform with powerful DevOps features.


#Key Features

FeatureDescription
RepositoriesCode hosting
Pull RequestsCode review
ActionsCI/CD workflows
IssuesProject tracking
PackagesArtifact registry
CodespacesCloud dev environments

#GitHub Actions Basics

yaml
1# .github/workflows/ci.yml
2name: CI
3
4on:
5  push:
6    branches: [main]
7  pull_request:
8    branches: [main]
9
10jobs:
11  build:
12    runs-on: ubuntu-latest
13    
14    steps:
15      - uses: actions/checkout@v4
16      
17      - name: Setup Node.js
18        uses: actions/setup-node@v4
19        with:
20          node-version: '20'
21      
22      - name: Install dependencies
23        run: npm ci
24      
25      - name: Run tests
26        run: npm test
27      
28      - name: Build
29        run: npm run build

#Branch Protection

  1. Go to Settings → Branches
  2. Add rule for main
  3. Enable:
    • Require pull request reviews
    • Require status checks
    • Require conversation resolution

#Useful CLI Commands

bash
1# Install GitHub CLI
2brew install gh
3
4# Authentication
5gh auth login
6
7# Create repository
8gh repo create my-repo --public
9
10# Create pull request
11gh pr create --title "Feature X" --body "Description"
12
13# View PRs
14gh pr list
15gh pr view 123
16
17# Merge PR
18gh pr merge 123
19
20# View Actions
21gh run list
22gh run view

[!TIP] Pro Tip: Use GitHub Actions for everything - CI, CD, scheduled tasks, and automation!