- Created example Markdown document with basic formatting and code block. - Added configuration file for site settings including base URL and author. - Introduced index page with project overview and links to documentation. - Implemented detailed documentation for create_repo.sh, including usage, prerequisites, and response codes. - Added custom 404 error page for better user experience. - Developed HTML structure for create_repo.sh documentation with styling and layout. - Created main index page with project description and links to relevant resources. - Included robots.txt and sitemap.xml for search engine optimization. - Established CSS styles for consistent design across the site. - Set up base HTML template for consistent layout and navigation. - Created templates for index and page rendering to streamline content management.
93 lines
4.5 KiB
HTML
93 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>create_repo.sh — Documentation DevOps</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="http://127.0.0.1:1111/style.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css">
|
|
</head>
|
|
<body>
|
|
<div class="topbar">
|
|
<div class="topbar-inner">
|
|
<a class="brand" href="http://127.0.0.1:1111">
|
|
<span class="logo">⚙</span> Documentation DevOps
|
|
</a>
|
|
<nav class="nav-links">
|
|
<a href="http://127.0.0.1:1111">Accueil</a>
|
|
<a href="http://127.0.0.1:1111/create-repo/">create_repo.sh</a>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<main class="wrap">
|
|
|
|
<article class="article">
|
|
<h1>create_repo.sh</h1>
|
|
<p>Script Bash qui <strong>crée un dépôt sur la forge</strong> (<code>forge.gwenaelremond.fr</code>) en
|
|
appelant son API REST.</p>
|
|
<h2 id="a-quoi-ca-sert">À quoi ça sert</h2>
|
|
<p>Plutôt que de retaper une longue commande <code>curl</code> à chaque fois, le script prend
|
|
le <strong>nom</strong> et la <strong>description</strong> du dépôt en arguments, et lit le <strong>token
|
|
d'authentification</strong> dans une variable d'environnement (pour ne jamais l'écrire
|
|
en dur dans le code).</p>
|
|
<h2 id="prerequis">Prérequis</h2>
|
|
<ul>
|
|
<li><code>curl</code> (installé par défaut sur macOS et Linux)</li>
|
|
<li>Un <strong>token d'accès</strong> à la forge (Settings → Applications → Generate New Token)</li>
|
|
</ul>
|
|
<h2 id="utilisation">Utilisation</h2>
|
|
<pre><code data-lang="bash"># 1. Définir le token (une seule fois par session de terminal)
|
|
export FORGE_TOKEN="ton_token"
|
|
|
|
# 2. Lancer le script
|
|
./create_repo.sh <nom_du_repo> ["description"]
|
|
</code></pre>
|
|
<h3 id="exemple">Exemple</h3>
|
|
<pre><code data-lang="bash">export FORGE_TOKEN="b103fb7f..."
|
|
./create_repo.sh exercice "Adam"
|
|
</code></pre>
|
|
<p>Cela crée le dépôt <strong>exercice</strong> avec la description <strong>Adam</strong>.</p>
|
|
<h2 id="detail-du-fonctionnement">Détail du fonctionnement</h2>
|
|
<table><thead><tr><th>Partie du script</th><th>Rôle</th></tr></thead><tbody>
|
|
<tr><td><code>set -euo pipefail</code></td><td>Arrête le script à la moindre erreur (sécurité)</td></tr>
|
|
<tr><td>Vérification de <code>FORGE_TOKEN</code></td><td>Refuse de tourner si le token n'est pas défini</td></tr>
|
|
<tr><td><code>REPO_NAME</code> / <code>REPO_DESC</code></td><td>Récupère les arguments passés en ligne de commande</td></tr>
|
|
<tr><td><code>curl -X POST .../api/v1/user/repos</code></td><td>Envoie la requête de création à l'API</td></tr>
|
|
</tbody></table>
|
|
<h3 id="la-requete-envoyee">La requête envoyée</h3>
|
|
<pre><code data-lang="bash">curl -X POST "https://forge.gwenaelremond.fr/api/v1/user/repos" \
|
|
-H "Authorization: token $FORGE_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-H "accept: application/json" \
|
|
-d '{ "name": "exercice", "description": "Adam" }'
|
|
</code></pre>
|
|
<h2 id="codes-de-reponse-possibles">Codes de réponse possibles</h2>
|
|
<table><thead><tr><th>Code HTTP</th><th>Signification</th></tr></thead><tbody>
|
|
<tr><td><code>201</code></td><td>Dépôt créé avec succès</td></tr>
|
|
<tr><td><code>409</code></td><td>Un dépôt portant ce nom existe déjà</td></tr>
|
|
<tr><td><code>401</code></td><td>Token invalide ou manquant</td></tr>
|
|
</tbody></table>
|
|
<h2 id="bonne-pratique-de-securite">Bonne pratique de sécurité</h2>
|
|
<p>⚠️ <strong>Ne jamais écrire le token en clair</strong> dans le script ni le commiter dans Git.
|
|
Si un token a été exposé, le <strong>révoquer</strong> et en générer un nouveau dans les
|
|
paramètres de la forge.</p>
|
|
|
|
<a class="back-link" href="http://127.0.0.1:1111">← Retour à l'accueil</a>
|
|
</article>
|
|
|
|
</main>
|
|
|
|
|
|
<footer>
|
|
Généré avec <strong>Zola</strong> · Adam
|
|
</footer>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
|
<script>hljs.highlightAll();</script>
|
|
</body>
|
|
</html>
|