Skip to content

Commit 281fd34

Browse files
committed
convert site from jekyll to mkdocs
1 parent a6ea9c9 commit 281fd34

File tree

5,229 files changed

+16050
-152585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,229 files changed

+16050
-152585
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Cleanup branch
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
workflow_dispatch:
7+
inputs:
8+
cleanup_branch:
9+
description: "Nom de la branche à nettoyer"
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
16+
concurrency:
17+
group: deploy-${{ github.repository }}
18+
cancel-in-progress: false
19+
20+
jobs:
21+
cleanup:
22+
permissions:
23+
pages: write
24+
id-token: write
25+
issues: write
26+
pull-requests: write
27+
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Get artifact ID from the latest successful run
34+
id: get_artifact
35+
uses: actions/github-script@v6
36+
with:
37+
script: |
38+
const { owner, repo } = context.repo;
39+
const workflow_id = '.github/workflows/github-actions.yml'; // Remplace par ton vrai fichier
40+
41+
console.log('Récupération des derniers artefacts');
42+
const runs = await github.rest.actions.listWorkflowRuns({
43+
owner,
44+
repo,
45+
workflow_id: workflow_id,
46+
status: "success",
47+
per_page: 1
48+
});
49+
50+
if (runs.data.total_count === 0) {
51+
console.log("Aucun artefact trouvé. On continue quand même.");
52+
return;
53+
}
54+
55+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
56+
owner,
57+
repo,
58+
run_id: runs.data.workflow_runs[0].id
59+
});
60+
61+
const artifact = artifacts.data.artifacts.find(a => a.name === "github-pages");
62+
if (artifact) {
63+
console.log("Artifact trouvé avec ID :", artifact.id);
64+
const response = await github.rest.actions.downloadArtifact({
65+
owner,
66+
repo,
67+
artifact_id: artifact.id,
68+
archive_format: 'zip'
69+
});
70+
require('fs').writeFileSync("github-pages.zip", Buffer.from(response.data));
71+
require('child_process').execSync(`unzip -o github-pages.zip -d "/tmp/gh-artifact-extract" && mkdir -p docs/site && tar xvf /tmp/gh-artifact-extract/artifact.tar -C docs/site/`);
72+
console.log("Artefact téléchargé et extrait");
73+
} else {
74+
console.log("Aucun artefact trouvé.");
75+
}
76+
77+
- name: Lister les fichiers de l'artefact
78+
run: |
79+
echo "📂 Contenu de l'artefact après extraction :"
80+
ls -R /tmp/gh-artifact-extract/
81+
82+
- name: Supprimer le dossier associé à la PR fermée
83+
run: |
84+
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
85+
echo "📂 Vérification du contenu :"
86+
ls -l docs/site/
87+
88+
folder_path="docs/site/${branch_name}"
89+
echo "🛠️ Dossier ciblé : $folder_path"
90+
91+
if [ ! -d "$folder_path" ]; then
92+
echo "❌ Aucun dossier trouvé pour la branche ${branch_name} !"
93+
exit 1
94+
else
95+
rm -rf "$folder_path"
96+
echo "✅ Dossier supprimé avec succès."
97+
fi
98+
99+
ls -l docs/site/
100+
101+
- name: Upload static files as artifact
102+
uses: actions/upload-pages-artifact@v3
103+
with:
104+
path: docs/site
105+
106+
- name: Post cleanup comment
107+
uses: actions/github-script@v7
108+
if: github.event_name == 'pull_request_target'
109+
with:
110+
github-token: ${{ secrets.GITHUB_TOKEN }}
111+
script: |
112+
github.rest.issues.createComment({
113+
issue_number: context.payload.pull_request.number,
114+
owner: context.repo.owner,
115+
repo: context.repo.repo,
116+
body: '🚀 Cleanup completed for PR and associated branch: [${{ github.event.pull_request.head.ref }}]'
117+
});

.github/workflows/doc-deploy.yml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: Deploy MkDocs
2+
3+
on:
4+
push:
5+
branches:
6+
- 1811_testpr
7+
- 1811_mkdocs_documentation_website
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: deploy-${{ github.repository }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.event.pull_request.head.ref }}
23+
repository: ${{ github.event.pull_request.head.repo.full_name }}
24+
25+
- name: Get artifact ID from the latest successful run
26+
id: get_artifact
27+
uses: actions/github-script@v6
28+
with:
29+
script: |
30+
const { owner, repo } = context.repo;
31+
const workflow_id = 'github-actions.yml';
32+
33+
console.log('Récupération des derniers artefacts');
34+
const runs = await github.rest.actions.listWorkflowRuns({
35+
owner,
36+
repo,
37+
workflow_id: workflow_id,
38+
status: "success",
39+
per_page: 1
40+
});
41+
42+
if (runs.data.total_count === 0) {
43+
console.log("Aucun artefact trouvé. On continue quand même.");
44+
return;
45+
}
46+
47+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
48+
owner,
49+
repo,
50+
run_id: runs.data.workflow_runs[0].id
51+
});
52+
53+
const artifact = artifacts.data.artifacts.find(a => a.name === "github-pages");
54+
if (artifact) {
55+
console.log("Artifact trouvé avec ID :", artifact.id);
56+
const response = await github.rest.actions.downloadArtifact({
57+
owner,
58+
repo,
59+
artifact_id: artifact.id,
60+
archive_format: 'zip'
61+
});
62+
require('fs').writeFileSync("github-pages.zip", Buffer.from(response.data));
63+
require('child_process').execSync(`unzip -o github-pages.zip -d "/tmp/gh-artifact-extract" && mkdir -p docs/site && tar xvf /tmp/gh-artifact-extract/artifact.tar -C docs/site/`);
64+
console.log("Artefact téléchargé et extrait");
65+
} else {
66+
console.log("Aucun artefact trouvé.");
67+
}
68+
69+
- uses: actions/setup-python@v5
70+
with:
71+
python-version: 3.13.0
72+
73+
- name: Install dependencies
74+
run: |
75+
echo "Installation des dépendances"
76+
pip install -r docs/requirements.txt
77+
78+
- name: Build MkDocs site
79+
run: |
80+
echo "Compilation du site MkDocs"
81+
cd docs
82+
mkdocs build --site-dir site/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
83+
84+
- name: Upload static files as artifact
85+
id: deployment
86+
uses: actions/upload-pages-artifact@v3
87+
with:
88+
path: docs/site
89+
90+
deploy:
91+
needs: build
92+
permissions:
93+
pages: write
94+
id-token: write
95+
issues: write
96+
pull-requests: write
97+
98+
environment:
99+
name: github-pages
100+
url: ${{ steps.deployment.outputs.page_url }} # L'URL qui sera affichée dans l'environnement
101+
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Deploy to GitHub Pages
105+
id: deployment
106+
uses: actions/deploy-pages@v4
107+
108+
- name: Override page_url
109+
id: change-page-url
110+
run: |
111+
echo "Mise à jour de l'URL de déploiement"
112+
if [[ "${GITHUB_REF}" == "refs/heads/1811_testpr" ]]; then
113+
echo "new_page_url=https://titouvgx.github.io/tock/1811_testpr/" >> $GITHUB_OUTPUT
114+
elif [[ "${GITHUB_REF}" == "refs/heads/1811_mkdocs_documentation_website" ]]; then
115+
echo "new_page_url=https://titouvgx.github.io/tock/1811_mkdocs_documentation_website/" >> $GITHUB_OUTPUT
116+
fi
117+
118+
- uses: actions/github-script@v7
119+
name: Post comment
120+
if: ${{ github.event_name == 'pull_request_target' }}
121+
with:
122+
github-token: ${{ secrets.GITHUB_TOKEN }}
123+
script: |
124+
console.log('Commentaire sur la PR :');
125+
github.rest.issues.createComment({
126+
issue_number: context.payload.pull_request.number,
127+
owner: context.repo.owner,
128+
repo: context.repo.repo,
129+
body: 'Website is published: [${{ steps.change-page-url.outputs.new_page_url }}](${{ steps.change-page-url.outputs.new_page_url }})'
130+
});
131+
132+
# cleanup:
133+
# needs: deploy
134+
# permissions:
135+
# pages: write
136+
# id-token: write
137+
# issues: write
138+
# pull-requests: write
139+
140+
# runs-on: ubuntu-latest
141+
# steps:
142+
# - name: Get artifact ID from the latest successful run
143+
# id: get_artifact
144+
# uses: actions/github-script@v6
145+
# with:
146+
# script: |
147+
# const { owner, repo } = context.repo;
148+
# const workflow_id = 'github-actions.yml';
149+
150+
# console.log('Récupération des derniers artefacts');
151+
# const runs = await github.rest.actions.listWorkflowRuns({
152+
# owner,
153+
# repo,
154+
# workflow_id: workflow_id,
155+
# status: "success",
156+
# per_page: 1
157+
# });
158+
159+
# if (runs.data.total_count === 0) {
160+
# console.log("Aucun artefact trouvé. On continue quand même.");
161+
# return;
162+
# }
163+
164+
# const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
165+
# owner,
166+
# repo,
167+
# run_id: runs.data.workflow_runs[0].id
168+
# });
169+
170+
# const artifact = artifacts.data.artifacts.find(a => a.name === "github-pages");
171+
# if (artifact) {
172+
# console.log("Artifact trouvé avec ID :", artifact.id);
173+
# const response = await github.rest.actions.downloadArtifact({
174+
# owner,
175+
# repo,
176+
# artifact_id: artifact.id,
177+
# archive_format: 'zip'
178+
# });
179+
# require('fs').writeFileSync("github-pages.zip", Buffer.from(response.data));
180+
# require('child_process').execSync(`unzip -o github-pages.zip -d "/tmp/gh-artifact-extract" && mkdir -p docs/site && tar xvf /tmp/gh-artifact-extract/artifact.tar -C docs/site/`);
181+
# console.log("Artefact téléchargé et extrait");
182+
# } else {
183+
# console.log("Aucun artefact trouvé.");
184+
# }
185+
186+
# - name: Supprimer le dossier associé à la PR fermée
187+
# run: |
188+
# branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
189+
# echo "branch_name: $branch_name"
190+
191+
# echo "📂 Contenu extrait de artifact.tar :"
192+
# ls -l docs/site/
193+
194+
# folder_path="docs/site/${branch_name}"
195+
# echo "folder_path: $folder_path"
196+
197+
# if [ -z "$folder_path" ]; then
198+
# echo "❌ Aucun dossier trouvé pour la branche ${branch_name} !"
199+
# exit 1
200+
# else
201+
# echo "🛠️ Chemin réel du dossier à supprimer : $folder_path"
202+
# rm -rf "$folder_path"
203+
# echo "✅ Dossier supprimé avec succès."
204+
# fi
205+
206+
# ls -l docs/site/
207+
208+
# - name: Upload static files as artifact
209+
# id: deployment
210+
# uses: actions/upload-pages-artifact@v3
211+
# with:
212+
# path: docs/site
213+
214+
# - name: Post cleanup comment
215+
# run: |
216+
# echo "Commentaire après nettoyage"
217+
# github.rest.issues.createComment({
218+
# issue_number: context.payload.pull_request.number,
219+
# owner: context.repo.owner,
220+
# repo: context.repo.repo,
221+
# body: 'Cleanup completed for PR and associated branch: [${{ github.event.pull_request.head.ref }}]'
222+
# });
223+
224+

0 commit comments

Comments
 (0)