-
Notifications
You must be signed in to change notification settings - Fork 0
fix(repo-maintenance): Quality Gate 必須チェックの fallback ワークフローを配布対象に追加 #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Quality Gate Fallback | ||
| # | ||
| # Required Status Check "Quality Gate" を必ず報告するための fallback ワークフロー。 | ||
| # | ||
| # 必要な背景: | ||
| # - setup-team-protection.sh はブランチ保護に "Quality Gate" を必須チェックとして登録する | ||
| # - ci.yml の Quality Gate ジョブが paths フィルタでスキップされた場合や、 | ||
| # ci.yml 自体が存在しない / 走らない場合、PR は永遠に | ||
| # "Expected — Waiting for status to be reported" のまま blocked になる | ||
| # - この fallback は ci.yml の実行可否をチェックし、走っていなければ Pass を emit する | ||
| # | ||
| # 動作: | ||
| # - ci.yml が走っている / 成功している場合 → 何もしない (本体の Quality Gate が優先) | ||
| # - ci.yml が走っていない場合 → Pass で Quality Gate を emit | ||
| # | ||
| # 使い方: | ||
| # .github/workflows/quality-gate-fallback.yml にコピーして配置 | ||
| # setup-team-protection.sh で "Quality Gate" を必須チェックに設定する場合は必須 | ||
| # | ||
| # 既知の制限: | ||
| # - GITHUB_TOKEN で push されたコミット (claude[bot] / dependabot[bot] が | ||
| # GITHUB_TOKEN で押した場合など) では `pull_request` イベントが発火しないため、 | ||
| # この fallback も実行されない。その場合は別途 PAT 経由の push か | ||
| # workflow_dispatch / repository_dispatch での再トリガーが必要。 | ||
| # | ||
| name: CI Fallback | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main, master, pre-production, production] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| actions: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-fallback | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| quality-gate: | ||
| name: Quality Gate | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 2 | ||
| steps: | ||
| - name: Check if CI workflow ran | ||
| id: check | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 | ||
| with: | ||
| script: | | ||
| try { | ||
| const { data: runs } = await github.rest.actions.listWorkflowRunsForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| head_sha: context.sha, | ||
| per_page: 20, | ||
| }); | ||
|
|
||
| const ciRun = runs.workflow_runs.find( | ||
| r => r.name === 'CI' && r.id !== context.runId | ||
| ); | ||
|
|
||
| if (ciRun && ciRun.status !== 'completed') { | ||
| core.info(`CI workflow is running (${ciRun.html_url}), this fallback is not needed.`); | ||
| core.setOutput('ci_running', 'true'); | ||
| } else if (ciRun && ciRun.conclusion === 'success') { | ||
| core.info(`CI workflow already succeeded (${ciRun.html_url}).`); | ||
| core.setOutput('ci_running', 'true'); | ||
| } else { | ||
| core.info('CI workflow did not run for this commit. Providing fallback Quality Gate.'); | ||
| core.setOutput('ci_running', 'false'); | ||
| } | ||
| } catch (err) { | ||
| // 権限不足 (actions: read 未付与) や一時的な API 障害でクエリ失敗時は | ||
| // 安全側に倒す。"CI 実行中扱い" にして fallback の Pass emit をスキップし、 | ||
| // 本体の Quality Gate (ci.yml) の結果を待つ。Required check が | ||
| // 未報告のままになる可能性はあるが、誤った Pass / Fail よりは安全。 | ||
| core.warning(`Could not query workflow runs (${err.status || err.message}). Skipping fallback.`); | ||
| core.setOutput('ci_running', 'true'); | ||
| } | ||
|
|
||
| - name: Pass (CI skipped) | ||
| if: steps.check.outputs.ci_running == 'false' | ||
| run: echo "Quality Gate passed (CI skipped — no code changes detected or workflow disabled)." | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: keito4/config
Length of output: 96
🏁 Script executed:
Repository: keito4/config
Length of output: 1008
🏁 Script executed:
Repository: keito4/config
Length of output: 2593
🏁 Script executed:
Repository: keito4/config
Length of output: 39
🏁 Script executed:
Repository: keito4/config
Length of output: 2308
🏁 Script executed:
Repository: keito4/config
Length of output: 5022
🏁 Script executed:
Repository: keito4/config
Length of output: 1259
🏁 Script executed:
Repository: keito4/config
Length of output: 39
Hardcoding
maincreates inconsistency with multi-branch protection logic.The Quality Gate check only inspects
branches/main, but the script'sPROTECT_BRANCHESlogic supportsmain,pre-production, andproductionfor Next.js projects. When Quality Gate is registered as required onpre-productionorproduction, the hardcoded check misses them, incorrectly determining no fallback is needed and allowing the PR to block on "Expected — Waiting for status to be reported."Dynamic branch detection is needed to align with the protection scope.
🤖 Prompt for AI Agents