Synthèse automatique
Cette compétence explique comment brancher les échecs d'un workflow (Playwright ou autre journal capturé) sur l'action composite `.github/actions/post-failure-comment`, qui nettoie le journal via gitleaks et publie ou met à jour un commentaire de PR marqué.
Points forts
- Fournit des exemples de configuration complets pour les workflows à job unique, à jobs multiples et déclenchés manuellement, avec le bon conditionnement (`failure()`/`success()` versus `needs.<job>.result`).
- Justifie le besoin de façon concrète : les logs de workflow sont inaccessibles à l'agent (pas de `gh`, 403 sur l'API des logs), alors que les commentaires de PR sont lisibles via les webhooks et le serveur MCP GitHub.
- Décrit une action autonome qui résout ses scripts via `${{ github.action_path }}`, donc réutilisable sans dépendre d'un répertoire `scripts/` à la racine du dépôt consommateur.
- Explique la déduplication par marqueur et le mode `resolve` pour refermer automatiquement le commentaire quand le run repasse au vert.
Limites
- Très spécifique à un dépôt donné : elle suppose l'existence préalable de l'action composite et d'un marqueur unique par workflow.
- Ne documente pas la création de l'action elle-même ni le format exact du journal attendu en entrée.
- Le texte fourni est tronqué au niveau de la section sur le conditionnement supplémentaire, donc certains cas de filtrage restent partiellement décrits.
À utiliser lorsqu'on ajoute un workflow long ou Playwright dont les échecs doivent devenir lisibles directement dans la conversation de la PR, ou lorsqu'on veut remplacer des blocs inline de nettoyage gitleaks et de commentaire par l'action partagée.
À éviter si le dépôt ne dispose pas déjà de l'action composite `post-failure-comment`, ou si les échecs peuvent être diagnostiqués directement dans les logs sans passer par un commentaire de PR.
Analyse de sécurité
SûrThe skill is purely instructional documentation for configuring a GitHub Actions composite action that scrubs logs with gitleaks and posts comments to a PR. It contains no executable shell commands, no destructive actions, no exfiltration, and explicitly emphasizes secret scrubbing. The YAML snippets are standard workflow configuration.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
I just added a new Playwright workflow that runs on PRs. Make its failures self-report into the PR conversation using our post-failure-comment composite action, including resolving the comment when the run goes green.Our e2e matrix runs in one job and the comment step lives in the finalize job, but it never posts on failures. Can you switch the conditions to gate on needs.e2e.result instead of failure()/success() and use the e2e-failure-summary marker?There are several workflows with copy-pasted gitleaks scrub and gh pr comment blocks. Refactor them to call ./.github/actions/post-failure-comment in both post and resolve modes.name: post-failure-comment
description: Wire a workflow's Playwright (or other captured-log) failures into the PR conversation as a marker-tagged, secret-scrubbed comment via the .github/actions/post-failure-comment composite action. Use when adding a new long-running/Playwright workflow, when a workflow's failures are opaque to agents iterating on a PR, when the user asks to "make CI failures self-report", or when refactoring inline gitleaks-scrub-and-comment blocks into the shared action.
Failure-comment composite action
Why this exists
Workflow logs in this repo are not directly readable by the Claude agent (no gh CLI, no logs surface in the GitHub MCP server, actions/runs/.../logs returns 403 unauthenticated). When a long-running workflow fails on a PR, the agent has to either ask the user to paste the log or open the run in a browser.
The composite action at .github/actions/post-failure-comment/action.yml solves this: it scrubs the captured log via gitleaks and posts (or updates, via marker-based dedup) a PR comment with the failure block. PR comments arrive as <github-webhook-activity> events the agent can read directly, and are also fetchable via mcp__github__pull_request_read.
The action is self-contained: its extractor and scrubber scripts are co-located in the action's own directory and resolved via $ACTION_PATH (${{ github.action_path }}), so the action travels with whatever repo checks the platform out — there is no dependence on a scripts/ dir at the consuming site's root.
Built once; every Playwright-running workflow should call it.
Caller convention
The action is mode-driven with caller-side gating. Two call sites per workflow: one for the failure post, one for the green-run resolve. The action itself just does what its mode input tells it to — it does not try to detect job state.
Single-job workflow (most common)
The comment step lives in the SAME job as the Playwright run.
- name: Post failure summary
if: ${{ failure() && github.event_name == 'pull_request' }}
uses: ./.github/actions/post-failure-comment
with:
mode: post
log-file: /tmp/<your-log>.log
marker: <unique-marker-slug> # NO `<!-- -->` — the action wraps it
title: <short label> # shown in the comment heading
- name: Resolve failure summary on success
if: ${{ success() && github.event_name == 'pull_request' }}
uses: ./.github/actions/post-failure-comment
with:
mode: resolve
marker: <unique-marker-slug>
title: <short label>
Multi-job workflow
The comment step lives in a DOWNSTREAM job (e.g. finalize after an e2e matrix). failure() / success() reflect the FINALIZE job's state — not the matrix's — so gate on needs.<job>.result instead:
- if: ${{ needs.e2e.result == 'failure' && github.event_name == 'pull_request' }}
uses: ./.github/actions/post-failure-comment
with: { mode: post, log-file: /tmp/playwright-output.log, marker: e2e-failure-summary, title: E2E tests }
- if: ${{ needs.e2e.result == 'success' && github.event_name == 'pull_request' }}
uses: ./.github/actions/post-failure-comment
with: { mode: resolve, marker: e2e-failure-summary, title: E2E tests }
Non-pull_request triggers
For workflow_dispatch (or any event without a github.event.pull_request context), pass the parent PR explicitly and drop the github.event_name part of the if::
- if: failure()
uses: ./.github/actions/post-failure-comment
with:
mode: post
log-file: /tmp/<your-log>.log
marker: <unique-marker-slug>
title: <short label>
pr-number: ${{ inputs.pr_number }}
- if: success()
uses: ./.github/actions/post-failure-comment
with:
mode: resolve
marker: <unique-marker-slug>
title: <short label>
pr-number: ${{ inputs.pr_number }}
Gating the call further
For a workflow whose runtime gate matches the upload-artifact step (e.g. vars.PROD_PLAYGROUND_MODE == 'true'), match the if: on each call to the upload step's gate so the comment behaviour is consistent with the rest of the failure-handling chain. For example:
if: ${{ failure() && vars.PROD_PLAYGROUND_MODE == 'true' }}
if: ${{ success() && vars.PROD_PLAYGROUND_MODE == 'true' }}
Patterns that DON'T work — don't repeat
${{ job.status }}inwith:— silently expands to empty string inside a composite action'swith:block. Two iterations confirmed: no comment ever lands.failure()/success()inside the action's own stepif:— unreliable in composite contexts; whatever GitHub Actions evaluatesfailure()against inside a composite step doesn't reflect the calling job's state in our case.
The caller-side gating in the patterns above is the only approach that has been empirically confirmed to fire (PR #517 finalize job at run 25561744480 — first successful auto-comment after switching to v3 mode-driven design).
Required upstream conditions
-
Capture the log. The Playwright invocation must
2>&1 | tee /tmp/<your-log>.log. The action reads from this path verbatim. If the log is missing or empty, the action emits a "(no log captured)" comment instead of failing. -
Pin a unique marker. The action wraps
<your-marker>as<!-- your-marker -->. Two workflows MUST NOT share a marker — they will clobber each other's comments. Existing markers in use:e2e-failure-summary—e2e-tests.yml→finalize(aggregates the e2e matrix)unit-failure-summary—e2e-tests.yml→unite2e-real-failure-summary—e2e-tests.yml→e2e-realparity-failure-summary—e2e-tests.yml→parityselect-failure-summary—e2e-tests.yml→selecthost-loop-failure-summary—cms-publish-loop-host.ymlprod-mutate-failure-summary—cms-publish-loop-prod.ymlpreview-loop-failure-summary—cms-publish-loop-preview.yml
-
Check out the platform so the action is on disk. The action shells out to its co-located
$ACTION_PATH/extract-playwright-failures.shand$ACTION_PATH/scrub-secrets.js($ACTION_PATH=${{ github.action_path }}). The scripts ship inside the action's own directory, so you do NOT need ascripts/dir at the consuming repo's root — but the action's directory must be present, which means the workflow must check out the repo/path that contains.github/actions/post-failure-comment/(e.g. the reusablee2e-tests.ymlchecks the platform out into.cms-platform/and references the action as./.cms-platform/.github/actions/post-failure-comment). You still wantactions/checkoutfor the site so the captured log path exists, but the extractor + scrubber no longer depend on a site-rootscripts/dir. -
Grant
pull-requests: writeto the workflow. The defaultGITHUB_TOKENworks for posting comments on the same repo, BUT only if the workflow'spermissions:block explicitly grants it. Without this, the embeddedactions/github-scriptcall 403s silently — the workflow log shows the error but no comment is posted, which can fool a casual review. The composite action does NOT requireCMS_E2E_PAT. Minimum block:permissions: contents: read pull-requests: write
What the action does internally
| Step | Gate | Notes |
|---|---|---|
| Install gitleaks | outcome == 'failure' | Installs to $HOME/.local/bin (no sudo). Adds to $GITHUB_PATH so subsequent steps see it. |
| Extract & scrub | outcome == 'failure' | Runs $ACTION_PATH/extract-playwright-failures.sh; falls back to tail -c 80000 if the extractor finds nothing. Scrubs via $ACTION_PATH/scrub-secrets.js (gitleaks). Truncates to 60 KB. |
| Post comment | outcome == 'failure' AND (pull_request event OR pr-number set) | Marker-based update-or-create. |
| Resolve on success | outcome == 'success' AND (pull_request event OR pr-number set) | Replaces an existing failure comment with a "passing on <sha>" stub. |
The action no-ops on cancelled, skipped, or null outcomes — those rarely indicate a real failure that warrants a comment.
Security: env vars, not interpolation
Inputs to the embedded actions/github-script calls are passed via env: and read as process.env.X, not inlined as ${{ inputs.x }} into the script body. This is the pattern the github-script README explicitly requires; inlining input strings into a JS body is a classic script-injection vector. If you extend the action with new fields, follow the same pattern.
Security: gitleaks pass-through is non-optional
Every comment that lands on a PR via this action runs through $ACTION_PATH/scrub-secrets.js (which shells out to gitleaks detect --no-git --source <log>) inside the action's Extract and scrub failure summary step. There is no caller-side switch to disable it.
If you extend the action with new modes or new emit-paths, keep the scrubber call on every code path that emits log content into a comment body. A leaked PAT, AWS key, or token in failure output that bypasses gitleaks would be visible to anyone with read access to the PR (which on a public repo means the open internet, including search-engine indexers). The platform's secrets-scan.yml workflow prevents secrets from reaching git history; the gitleaks pass-through here is the equivalent guard for everything that reaches a PR comment.
Triple-check this when:
- Adding a new
mode:value (e.g.digest,summary, anything that emits log content). - Refactoring the extract / post sequence (don't accidentally hoist the github-script call above the scrubber).
- Adding a new fallback path inside the action's
Extract and scrub failure summarystep.
Common refactor pitfalls
- Missing
pull-requests: writepermission — the most subtle and most common. The defaultGITHUB_TOKENis read-only unless explicitly elevated; without elevation the comment-post 403s silently and the workflow looks like it ran the comment step but produced no comment. ALWAYS addpull-requests: writeto a workflow'spermissions:block when wiring this action in. Verified by listing PR comments after a deliberately-broken push (see "Testing your wiring" below). - The action's directory isn't on disk — happens when slotting the action into a one-step workflow that never checks out the repo/path holding
.github/actions/post-failure-comment/. The extractor + scrubber are co-located in that directory and resolved via$ACTION_PATH, so the action dir itself must be present (auses: ./...path can't resolve otherwise). In the reusable platform model the harness checks the platform out into.cms-platform/and references./.cms-platform/.github/actions/post-failure-comment. A separate siteactions/checkoutis still wanted so the captured log path exists. - Overlapping markers — copy-pasting from another workflow without changing the marker. Always pick a globally-unique slug.
- Wrong outcome source —
${{ job.status }}is the canonical source for single-job workflows. For workflows with multiple dependent jobs (likee2e-tests.yml's post-job), pass${{ needs.<job>.result }}instead — and rememberneeds.<job>.resultonly reflects ONE upstream job. If the workflow has multiple matrix jobs that should all gate the comment, AND-combine them in an intermediate step. - Skipping the gate on
pull_request— for workflows that ALSO fire onscheduleorworkflow_dispatch, the action'sif:will skip posting (no PR context) but the gitleaks install still runs. To save runtime, add&& github.event_name == 'pull_request'to the caller'sif:or usepr-numberfor explicit-target workflows.
When NOT to use this
- Non-Playwright workflows with short logs. The extractor matches Playwright's
--reporter=listblocks; for other tooling it falls back totail -c, which is usually less useful than the workflow's own native error output. If your workflow already prints a clear single-line error, a comment with 60 KB of tail noise is worse than no comment. - Workflows with no PR context AND no parent PR.
schedule-only workflows (e.g.canary-prod.yml) have no PR to comment on. Open an issue instead, which is whatcanary-prod.ymlalready does in itsif: failure()branch. - One-off / hotfix workflows. The marker dedup convention requires a stable name; ad-hoc workflows would pollute the PR with stale "passing" stubs.
Testing your wiring
- Push a deliberately-broken commit (e.g. add
await page.waitForTimeout(99999999)to a spec). - Watch for the workflow to fail.
- Check the PR for a new
<!-- your-marker -->comment — it should arrive ~30s after the workflow ends. - Push a fix that turns the workflow green.
- The comment should refresh to
## <title> passing on <sha>within ~30s of the green run.
Files
All three live together in the action's directory and travel with it (resolved at runtime via $ACTION_PATH = ${{ github.action_path }}):
.github/actions/post-failure-comment/action.yml— the composite action..github/actions/post-failure-comment/extract-playwright-failures.sh— awk-based extractor for Playwright--reporter=listfailure blocks..github/actions/post-failure-comment/scrub-secrets.js— gitleaks-backed scrubber. Replaces detected secrets in-place with<REDACTED:RuleID>.- AGENTS.md "Failure-comment composite action" — short reference; this skill is the long-form.
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/post-ci-failure-as-pr-comment-msjwk4q8/download' --output '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md.part' && mv '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md.part' '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md' && test -s '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/post-failure-comment' && cp -R '.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8' '.claude/skills/post-failure-comment'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8'openskills read 'post-ci-failure-as-pr-comment-msjwk4q8'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/post-ci-failure-as-pr-comment-msjwk4q8/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Configurer un canal de discussion avec SecretRefs
DevOps
Configurez des canaux de discussion avec des commandes non interactives, les secrets étant uniquement des SecretRefs. Couvre les étapes de collecte, modification, réparation et vérification.
Enquêter sur les échecs CI de ClickHouse
DevOps
Investigue un échec CI de ClickHouse de bout en bout à partir d'une URL de PR ou de rapport S3. Récupère les tests échoués, classe flaky vs vraie régression, et cherche des issues/fixes existants.
Revue de PR Ansible
DevOps
Examine une PR Ansible selon le processus standardisé du projet, incluant la validation des changelogs, la couverture de tests et le suivi des commentaires.