ci: Preview de déploiement sur les PRs (artifact + commentaire)#123
Conversation
Upload build output as artifact (7 days retention) and post a comment on the PR with a link to download and preview locally. Closes #72
|
Preview disponible : le site a été buildé avec succès. Téléchargez l'artifact |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e805076cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| retention-days: 7 | ||
|
|
||
| - name: Comment PR with preview link | ||
| if: github.event_name == 'pull_request' |
There was a problem hiding this comment.
Skip PR comment step for forked pull requests
This step runs on every pull_request, including forks, but fork/Dependabot PR runs typically get a read-only GITHUB_TOKEN; the script then calls issues.listComments and issues.createComment/updateComment, which require write permission and can return 403 Resource not accessible by integration. In that scenario the build succeeds but the workflow still fails at the end, blocking external contributions unless fork write tokens are explicitly enabled, so this step should be gated to trusted PRs or made non-blocking.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Ajoute une “preview” de site pour les Pull Requests via GitHub Actions, en uploadant le build Docusaurus comme artifact et en postant (ou mettant à jour) un commentaire sur la PR avec un lien vers le run.
Changes:
- Ajout des permissions nécessaires et d’une étape d’upload d’artifact
site-preview(rétention 7 jours) sur les PR. - Ajout d’une étape
github-scriptqui commente la PR avec les instructions de récupération/prévisualisation. - Mise à jour du commentaire existant au lieu d’en créer un nouveau à chaque run.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - main | ||
|
|
||
| permissions: | ||
| contents: read |
There was a problem hiding this comment.
Le script utilise l’API github.rest.issues.* (list/update/createComment). Avec permissions actuellement limité à contents: read + pull-requests: write, le GITHUB_TOKEN risque de ne pas avoir issues: write, ce qui fera échouer l’étape de commentaire (403). Ajoutez issues: write (et éventuellement retirez pull-requests: write si inutile) ou basculez vers des endpoints pulls.* cohérents avec la permission accordée.
| contents: read | |
| contents: read | |
| issues: write |
| retention-days: 7 | ||
|
|
||
| - name: Comment PR with preview link | ||
| if: github.event_name == 'pull_request' |
There was a problem hiding this comment.
Sur des PRs provenant de forks, GitHub réduit souvent les permissions du GITHUB_TOKEN et l’écriture de commentaires peut échouer, ce qui ferait tomber le job. Envisagez de conditionner cette étape aux PRs depuis le même repo (github.event.pull_request.head.repo.full_name == github.repository) ou de la rendre non-bloquante (continue-on-error: true) pour éviter de casser la CI des contributeurs externes.
| if: github.event_name == 'pull_request' | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository |
| const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | ||
| const body = `**Preview disponible** : le site a été buildé avec succès.\n\nTéléchargez l'artifact \`site-preview\` depuis [ce run](${runUrl}) pour prévisualiser le rendu localement (\`npx serve build/\`).`; | ||
|
|
||
| // Check for existing preview comment to avoid duplicates | ||
| const comments = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| }); | ||
| const existing = comments.data.find(c => c.body.includes('Preview disponible')); |
There was a problem hiding this comment.
La détection du commentaire existant repose sur includes('Preview disponible') et listComments sans pagination (30 commentaires par défaut). Ça peut rater le commentaire à mettre à jour (ou matcher un commentaire utilisateur), et dupliquer. Ajoutez un marqueur stable (ex: un HTML comment unique) et utilisez github.paginate / per_page: 100 pour parcourir toutes les pages avant de décider update vs create.
| const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | |
| const body = `**Preview disponible** : le site a été buildé avec succès.\n\nTéléchargez l'artifact \`site-preview\` depuis [ce run](${runUrl}) pour prévisualiser le rendu localement (\`npx serve build/\`).`; | |
| // Check for existing preview comment to avoid duplicates | |
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.data.find(c => c.body.includes('Preview disponible')); | |
| const previewMarker = '<!-- site-preview-comment -->'; | |
| const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | |
| const body = `${previewMarker} | |
| **Preview disponible** : le site a été buildé avec succès.\n | |
| Téléchargez l'artifact \`site-preview\` depuis [ce run](${runUrl}) pour prévisualiser le rendu localement (\`npx serve build/\`).`; | |
| // Check for existing preview comment to avoid duplicates | |
| const comments = await github.paginate( | |
| github.rest.issues.listComments, | |
| { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| per_page: 100, | |
| }, | |
| ); | |
| const existing = comments.find( | |
| (c) => typeof c.body === 'string' && c.body.includes(previewMarker), | |
| ); |
Replace artifact upload + comment approach with Netlify Deploy Preview. Add netlify.toml with build config. Remove artifact/comment steps from build.yml. Netlify provides automatic deploy preview URLs on every PR with zero workflow maintenance. Closes #72
|
Les commentaires portent sur l'ancien code (artifact + commentaire PR) qui a été supprimé en e8e0d8f. La PR actuelle ne contient plus de step d'upload artifact ni de commentaire — uniquement l'ajout de |
Summary
netlify.tomlavec la config de build (Node 22, publishbuild/)Configuration Netlify (à faire manuellement)
steamicc/wiki_steamisur app.netlify.comnetlify.tomldeploy-preview-123--wiki-steami.netlify.app)Closes #72
Test plan