ci: 自動更新 PR が無検証で提案されるのを止める - #1001
Merged
Merged
Conversation
The pull request check-update.yml opens is created with GITHUB_TOKEN, and GitHub does not trigger workflows for events raised by that token. lint.yml therefore never runs on it: #968 has been open since 2025-10-18, has been updated daily since, and carries no checks whatsoever. It is the one path into this repository that nothing verifies, and it is also the busiest. Generating and validating in this job is the only place a check can be made to run at all. It is not a gate: one malformed upstream entry would otherwise withhold every valid update batched alongside it, and the point is to make the problem visible, not to suppress the whole batch. Both steps use continue-on-error, the outcome is written into the pull request body, and the job exits non-zero afterwards so the scheduled run still turns red. They stay on the runner's default shell and are kept as separate steps rather than one bash block: this job runs on windows-latest, and a single multi-line PowerShell step only propagates the exit code of its last command, which would let a failed generation pass as a successful check. The token expression is the upgrade path. Adding a CREATE_PR_TOKEN secret makes the pull request trigger lint.yml and CodeQL like any other, at which point this check becomes a pre-flight rather than the only one. Without the secret nothing changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
check-update.ymlが作る PR はGITHUB_TOKENで作成されるため、GitHub の再帰防止によってワークフローを一切トリガしません。lint.ymlも CodeQL も走らないので、#968 は 2025-10-18 に開かれて以来、毎日更新され続けているのにチェックが 0 件です。このリポジトリでいちばん頻繁にデータが入る経路が、唯一まったく検証されていない経路でもある、という状態でした。
やったこと
PR を作る前に生成と検証を回し、結果を PR 本文に書き込みます。
PR 本文にはこう入ります。
失敗した場合は
**FAILED** — check the workflow run before mergingになります。設計上の判断
ゲートにしていません
前回の PR で選択肢として挙げた「check-update 内検証」には「1 件でも不正だと更新 PR ごと止まる」という欠点がありました。これを避けています。
continue-on-error: true— 検証が落ちても PR は作られます不正なデータが 1 件混ざったせいで、同じバッチの正常な更新まで差し止められるより、見える形で提案されるほうが良いという判断です。公開の手前には #997 で入れた
release.ymlのゲートがあるので、最終防波堤はそちらが担います。bash を使わず 2 ステップに分けています
この job は
windows-latestで動きます。複数行のrun:は既定で PowerShell になり、GitHub が付ける終了コードのチェックは最後のコマンドしか見ません。1 ステップにまとめると、生成が失敗しても検証が成功すればステップ全体が通ってしまいます。shell: bashに切り替える手もありますが、Windows ランナーに Git Bash 依存を持ち込むより、既存のyarnステップと同じ既定シェルのまま分けるほうが安全と判断しました。完全な解決には PAT が要ります(要メンテナ操作)
この検証はスキーマ検証だけで、prettier / eslint / CodeQL は依然走りません。それらまで走らせるには PR の作成者を変える必要があります。
そのための入口を 1 行だけ用意しました。
CREATE_PR_TOKENという名前で PAT をシークレット登録するだけで、自動更新 PR が通常どおり全ワークフローをトリガするようになります。シークレットが無い間は今と同じ挙動のままです(存在しないシークレットは空文字列に評価され、フォールバックが効きます)。PAT の発行と登録は資格情報の取り扱いなので、こちらでは行いません。
確認したこと
prettier --checkが緑