Skip to content

ci: Preview de déploiement sur les PRs (artifact + commentaire)#123

Merged
nedseb merged 3 commits into
mainfrom
ci/deploy-preview
Mar 23, 2026
Merged

ci: Preview de déploiement sur les PRs (artifact + commentaire)#123
nedseb merged 3 commits into
mainfrom
ci/deploy-preview

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 23, 2026

Summary

  • Ajout de netlify.toml avec la config de build (Node 22, publish build/)
  • Chaque PR recevra automatiquement une URL de deploy preview via Netlify

Configuration Netlify (à faire manuellement)

  1. Connecter le repo steamicc/wiki_steami sur app.netlify.com
  2. Netlify détecte automatiquement le netlify.toml
  3. Chaque PR recevra une URL de preview (ex: deploy-preview-123--wiki-steami.netlify.app)

Closes #72

Test plan

  • Connecter le repo sur Netlify
  • Vérifier qu'une PR génère une deploy preview avec URL cliquable
  • Vérifier que le build CI existant n'est pas impacté

nedseb added 2 commits March 23, 2026 14:21
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
@nedseb nedseb requested a review from Copilot March 23, 2026 13:22
@nedseb nedseb self-assigned this Mar 23, 2026
@nedseb nedseb added the enhancement New feature or request label Mar 23, 2026
@github-actions
Copy link
Copy Markdown

Preview disponible : le site a été buildé avec succès.

Téléchargez l'artifact site-preview depuis ce run pour prévisualiser le rendu localement (npx serve build/).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .github/workflows/build.yml Outdated
retention-days: 7

- name: Comment PR with preview link
if: github.event_name == 'pull_request'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-script qui 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
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
contents: read
contents: read
issues: write

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/build.yml Outdated
retention-days: 7

- name: Comment PR with preview link
if: github.event_name == 'pull_request'
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/build.yml Outdated
Comment on lines +77 to +86
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'));
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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),
);

Copilot uses AI. Check for mistakes.
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
@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 23, 2026

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 netlify.toml. Les deploy previews sont gérées entièrement par Netlify (pas de workflow custom). Ces commentaires ne sont donc plus applicables.

@nedseb nedseb merged commit b89b742 into main Mar 23, 2026
1 check passed
@nedseb nedseb deleted the ci/deploy-preview branch March 23, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: Ajouter un workflow de preview de déploiement sur les PRs

2 participants