Skip to content
Commencer

Open Source et standards de collaboration

SlidesPDFPPTX
Niveau : Intermediate
Durée : 1h30

Prérequis

  • Maîtriser les bases GitHub (branches, PRs, remotes) Ateliers 07-08
  • Avoir un compte GitHub et gh installé (Atelier 02)
  • Comprendre les licences de base

Objectifs d'apprentissage

  • Expliquer et exécuter le Fork workflow (fork → clone → upstream sync → PR)
  • Utiliser gh CLI pour repo, issue, pr, release, codespace
  • Structurer la gouvernance : README, CONTRIBUTING, CODEOWNERS, LICENSE, SECURITY, FUNDING
  • Activer Dependabot, Secret Scanning et la Security Policy

Pourquoi le Fork ? (et pas le push direct)

Section titled “Pourquoi le Fork ? (et pas le push direct)”

Dans l’open source ou une grande équipe, vous n’avez pas le droit d’écrire sur upstream (le dépôt officiel).

Sans Fork

git push origin main → 403 Forbidden → bloqué

Avec Fork

Fork (votre copie) → clone → PR → review → upstream décide

<pre dir="ltr" class="mermaid">flowchart LR U[Upstream&lt;br/&gt;joinhashcode/original] -- Fork --&gt; O[Origin&lt;br/&gt;votre fork] O -- clone --&gt; L[Local&lt;br/&gt;votre PC] L -- push --&gt; O O -- Pull Request --&gt; U</pre>
  1. Forker sur GitHub : bouton Fork sur upstream → crée votre-username/projet (origin) 2. Cloner votre fork : bash git clone https://github.com/votre-username/projet.git cd projet 3. Ajouter l’upstream : bash git remote add upstream https://github.com/upstream/projet.git git remote -v # origin https://github.com/votre-username/projet.git (fork) # upstream https://github.com/upstream/projet.git (original) 4. Travailler sur une branche : bash git switch -c feat/ma-contrib git commit -m "feat: add feature" 5. Synchroniser régulièrement : bash git fetch upstream git switch main git merge upstream/main # ou gh repo sync 6. Pousser & PR : bash git push -u origin feat/ma-contrib gh pr create --fill
Terminal window
# Voir les commits en retard
git log --oneline HEAD..upstream/main
git fetch upstream
git merge upstream/main
git push origin main # met à jour votre fork

Variante gh :

Terminal window
gh repo fork upstream/projet --clone --remote
gh repo sync

Commandes à exécuter

bash
# Cliquez sur les commandes à gauche pour les exécuter dans le simulateur
hashcode-academy:~$_

2. GitHub CLI (gh) — le terminal qui remplace le navigateur

Section titled “2. GitHub CLI (gh) — le terminal qui remplace le navigateur”

gh = GitHub dans le terminal. Auth, repo, issue, pr, release, codespace.

Terminal window
gh auth login
# GitHub.com → HTTPS → Yes → Paste token
gh auth status
Terminal window
gh repo clone joinhashcode/workshops
gh repo view --web
gh repo fork upstream/projet --clone
gh repo create mon-projet --public --license mit --clone
gh repo sync
Terminal window
gh issue list --limit 10
gh issue create --title "bug: login" --body "Closes #42"
gh issue view 42 --web
gh pr create --draft --fill
gh pr create --title "feat: add login" --body "Closes #42" --reviewer joinhashcode/team
gh pr view 42 --web
gh pr checkout 42
gh pr merge 42 --squash --delete-branch
gh pr list --state open
Terminal window
gh release create v1.0.0 --generate-notes
gh release view v1.0.0 --web
gh codespace create --repo joinhashcode/workshops
gh codespace list
gh codespace list --web

Commandes à exécuter

bash
# Cliquez sur les commandes à gauche pour les exécuter dans le simulateur
hashcode-academy:~$_

3. Gouvernance : les 7 fichiers qui font un dépôt pro

Section titled “3. Gouvernance : les 7 fichiers qui font un dépôt pro”
Fichier Où Rôle Exemple
README.md Racine Vitrine : quoi, pourquoi, comment installer/lancer Badges, installation, usage
CONTRIBUTING.md Racine ou .github/ Comment contribuer : branches, commits, tests CONTRIBUTING.md (racine)
CODEOWNERS .github/ Reviewers auto par chemin *.js @frontend
CODE_OF_CONDUCT.md Racine ou .github/ Règles de communauté Contributor Covenant
LICENSE Racine Légal : MIT, Apache, GPL LICENSE (texte complet)
SECURITY.md Racine ou .github/ Comment signaler une faille Email privé
FUNDING.yml .github/ Parrainage GitHub Sponsors
# Projet
![CI](https://github.com/user/repo/actions/workflows/ci.yml/badge.svg)
## Installation
npm install
## Usage
npm run dev
1. Fork → Branch `feat/xxx` depuis `main`
2. Commits Conventional Commits
3. Tests : npm test
4. PR avec template
# Frontend
*.js @joinhashcode/frontend-leads
*.tsx @joinhashcode/frontend-leads
# Docs
/docs/ @joinhashcode/docs-team
*.md @joinhashcode/docs-team
# Infra
/deploy/ @joinhashcode/devops-team
* @joinhashcode/tech-leads
  • MIT : faites ce que vous voulez, gardez la licence (populaire)
  • Apache 2.0 : MIT + brevets
  • GPL v3 : dérivés doivent rester GPL

Choisir : https://choosealicense.com ou gh repo create --license mit

github: [joinhashcode]
patreon: joinhashcode

Commandes à exécuter

bash
# Cliquez sur les commandes à gauche pour les exécuter dans le simulateur
hashcode-academy:~$_

  • Dependabot (.github/dependabot.yml) — scanne package.json, ouvre PR auto si vulnérabilité

    version: 2
    updates:
    - package-ecosystem: npm
    directory: '/'
    schedule: { interval: weekly }
  • Secret Scanning — bloque le push si clé API/mot de passe détecté

  • Security Policy (SECURITY.md) — canal privé pour signaler :

    # Security Policy
    Email: security@joinhashcode.com — ne pas ouvrir d'issue publique.
  • Ne jamais committer .env → .gitignore + git-secrets + gitleaks
  • Activer Dependabot alerts : Settings → Code security
  • Signer les commits (git commit -S -m "...") si exigé

Question

Qu'est-ce qu'upstream ?

Cliquer pour révéler la réponse
Réponse

Le dépôt original officiel (joinhashcode) que vous avez forké. origin = votre fork.

Cliquer pour voir la question
Question

Commande pour lier l'upstream ?

Cliquer pour révéler la réponse
Réponse

git remote add upstream https://github.com/upstream/projet.git

Cliquer pour voir la question
Question

Comment sync son fork ?

Cliquer pour révéler la réponse
Réponse

git fetch upstream → git switch main → git merge upstream/main → git push origin main (ou gh repo sync)

Cliquer pour voir la question
Question

Que fait gh pr create --draft --fill ?

Cliquer pour révéler la réponse
Réponse

Crée une PR draft en remplissant titre/body depuis les commits.

Cliquer pour voir la question
Question

À quoi sert CODEOWNERS ?

Cliquer pour révéler la réponse
Réponse

Notifie/requiert automatiquement des reviewers selon les fichiers (*.js → @frontend).

Cliquer pour voir la question
Question

Quel fichier définit la licence ?

Cliquer pour révéler la réponse
Réponse

LICENSE à la racine (MIT, Apache, GPL).

Cliquer pour voir la question
Question

Rôle de Dependabot ?

Cliquer pour révéler la réponse
Réponse

Scan les dépendances et propose des PR de mise à jour de sécurité.

Cliquer pour voir la question
Question

Où signaler une faille ?

Cliquer pour révéler la réponse
Réponse

Via SECURITY.md (canal privé), pas une issue publique.

Cliquer pour voir la question

1. Que fait git remote add upstream ?

2. Quel outil gère issues/PRs en CLI ?

3. Quel fichier définit les reviewers auto ?

4. Que fait Dependabot ?


Terminal window
# Fork workflow
gh repo fork upstream/projet --clone --remote
git remote -v # origin + upstream
git fetch upstream; git switch main; git merge upstream/main; git push origin main
gh repo sync
# gh
gh auth login; gh auth status
gh repo clone joinhashcode/workshops
gh issue list; gh issue create --title "bug"; gh issue view 42
gh pr create --draft --fill; gh pr view --web; gh pr checkout 42; gh pr merge --squash
gh release create v1.0.0 --generate-notes
gh codespace create --repo joinhashcode/workshops
# Gouvernance
ls .github/CODEOWNERS CONTRIBUTING.md LICENSE SECURITY.md
cat .github/CODEOWNERS

Votre Progression0%


  • Fork = votre copie ; upstream = l’original. Sync : fetch upstream → merge → push origin.
  • gh remplace le navigateur pour repo, issue, pr, release, codespace.
  • Gouvernance = README + CONTRIBUTING + CODEOWNERS + LICENSE + SECURITY.
  • Sécurité = Dependabot + Secret Scanning + SECURITY.md (canal privé).

Gouvernance posée, passons au versionnage sémantique et aux Releases GitHub.

Et maintenant ?

HashCode Workshops
Part of the JoinHashCode ecosystem

Ctrl + K Rechercher dans les workshops