Skip to content

Staging#345

Merged
is0692vs merged 12 commits into
mainfrom
staging
Apr 7, 2026
Merged

Staging#345
is0692vs merged 12 commits into
mainfrom
staging

Conversation

@is0692vs

@is0692vs is0692vs commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary:

  • promote the current staging branch to main
  • ship the staging-first PR enforcement and main-to-staging sync automation
  • include the latest dependency updates already verified on staging

Included changes:

  • ci: automate staging-first branch flow
  • ci: harden sync PR automation
  • chore(deps): bump the npm_and_yarn group across 2 directories with 1 update

Notes:

  • staging was synced with main first via sync: merge main back into staging #344 before opening this promotion PR
  • after this merges, direct non-staging PRs to main will be retargeted by the new workflow

Greptile Summary

このPRは、CI/CDのブランチ管理フローを2つの面から強化します。①enforce-staging-flow.sh から admin bypass ロジックを削除し、全ユーザーに staging-first ルールを均一適用するように変更。②新たに sync-main-to-staging.yml ワークフローと sync-main-to-staging.sh スクリプトを追加し、main へのプッシュ後に自動で main → staging の同期 PRを開くようにしました。

  • admin bypass の削除: author_has_admin_bypass() 関数と関連コードを削除。管理者権限を持つユーザーでも main 直接ターゲットの PR は staging にリターゲットされるようになります(意図的な変更)。
  • 同期自動化: main へのプッシュ時に sync-main-to-staging.sh が既存のオープン sync PR を確認し、なければ ahead_by が 0 かどうかチェックし、新規 sync PR を作成します。重複 PR 防止ロジックも組み込まれています。
  • ドキュメント更新: copilot-instructions.mdREADME.md を新しいフローに合わせて更新。
  • 軽微な指摘: sync-main-to-staging.ymlactions/checkout@v4 がコミット SHA にピン留めされていないため、アクション更新で予期せぬ挙動変化が生じる可能性があります(ベストプラクティス)。
  • 軽微な指摘: 自動生成 sync PR にはレビュアーやラベルが設定されていないため、見落とされるリスクがあります。

Confidence Score: 5/5

このPRはマージして安全です。CI/CD自動化スクリプトの追加・整理であり、アプリコードへの影響はありません。

残る指摘はすべてP2(スタイル・ベストプラクティス)であり、ロジック上のバグや運用上の致命的問題は見当たりません。admin bypass の削除は意図的かつ文書化されており、sync スクリプトの重複 PR チェック・dry-run 対応も適切です。

.github/scripts/sync-main-to-staging.sh.github/workflows/sync-main-to-staging.yml は新規追加ファイルのため、本番環境での初回動作を注視してください。

Important Files Changed

Filename Overview
.github/scripts/enforce-staging-flow.sh author_has_admin_bypass 関数と関連コードを削除。admin ユーザーも含む全員に staging-first ルールが均一適用されるよう変更。ロジック整合性に問題なし。
.github/scripts/sync-main-to-staging.sh 新規追加のスクリプト。重複 PR チェック・ahead_by ガード・DRY_RUN フラグが実装されており品質は高いが、自動生成 PR にレビュアー・ラベルが未設定。
.github/workflows/sync-main-to-staging.yml 新規ワークフロー。main へのプッシュで sync PR を自動作成。concurrency 設定も適切だが、actions/checkout@v4 が SHA にピン留めされていない。
.github/copilot-instructions.md main sync の説明を自動 PR ベースの記述に更新。内容・フローともに正確。
README.md admin bypass の記述と旧 main sync の説明を削除・更新。変更内容は新フローと一致している。

Sequence Diagram

sequenceDiagram
    participant Dev as 開発者
    participant GH as GitHub
    participant EW as enforce-staging-flow.yml
    participant SW as sync-main-to-staging.yml
    participant Script as sync-main-to-staging.sh

    Dev->>GH: feature → main の PR を作成
    GH->>EW: pull_request_target トリガー
    EW->>GH: PR のベースを staging に変更 (retarget)
    GH-->>Dev: コメント通知

    Dev->>GH: feature → staging の PR を作成・マージ
    Dev->>GH: staging → main の PR を作成・マージ
    GH->>SW: push to main トリガー
    SW->>Script: bash sync-main-to-staging.sh
    Script->>GH: open sync PR を検索
    alt sync PR が既存
        Script-->>SW: PR URL を出力して終了
    else sync PR なし
        Script->>GH: main vs staging の ahead_by を確認
        alt ahead_by > 0
            Script->>GH: main → staging の sync PR を作成
            GH-->>Dev: sync PR 通知
        else ahead_by = 0
            Script-->>SW: 同期不要として終了
        end
    end
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: .github/workflows/sync-main-to-staging.yml
Line: 21

Comment:
**アクションのSHAピン留めなし**

`actions/checkout@v4` がタグ参照のままです。タグが後から別のコミットに移動された場合、意図しないコード変更がワークフローに取り込まれるリスクがあります。セキュリティのベストプラクティスとしてコミット SHA にピン留めすることが推奨されます。

```suggestion
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: .github/scripts/sync-main-to-staging.sh
Line: 64-69

Comment:
**sync PR へのレビュアー・ラベル未設定**

自動生成される sync PR にレビュアーやラベルが設定されていないため、通知がなく見落とされる可能性があります。チームの運用フローによっては `--reviewer``--label` を追加すると PR が気づかれやすくなります。

```suggestion
gh pr create \
  --repo "$GH_REPO" \
  --base "$BASE_BRANCH" \
  --head "$HEAD_BRANCH" \
  --title "$title" \
  --body "$body" \
  --label "sync"
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Merge pull request #344 from Hiroki-org/..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Context used:

  • Context used - 日本語で!!! (source)

dependabot Bot and others added 6 commits April 7, 2026 00:25
…update

Bumps the npm_and_yarn group with 1 update in the / directory: [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite).
Bumps the npm_and_yarn group with 1 update in the /apps/web directory: [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite).


Updates `vite` from 7.3.1 to 7.3.2
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v7.3.2/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v7.3.2/packages/vite)

Updates `vite` from 7.3.1 to 7.3.2
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v7.3.2/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v7.3.2/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 7.3.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: vite
  dependency-version: 7.3.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
…nd_yarn-20b630b4a0

chore(deps): bump the npm_and_yarn group across 2 directories with 1 update
sync: merge main back into staging
@vercel

vercel Bot commented Apr 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
open-shelf Ignored Ignored Apr 7, 2026 8:30am

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e514b559-5551-430e-b475-bc192e386413

📥 Commits

Reviewing files that changed from the base of the PR and between 6d42ba1 and e883925.

📒 Files selected for processing (1)
  • .github/workflows/sync-main-to-staging.yml

📝 Walkthrough

Summary by CodeRabbit

  • Documentation

    • デプロイ運用フローを更新しました。main へのプッシュ後、自動で main → staging の同期 PR を作成または再利用する運用に変更しました。
  • Chores

    • main→staging 同期を自動化するワークフローと補助スクリプトを追加しました。
    • PR の自動リターゲット処理を簡素化し、管理者向けの例外(管理者バイパス)を廃止しました。

Walkthrough

main へのプッシュをトリガーに mainstaging の同期PRを自動で作成または再利用するワークフローとスクリプトを追加し、PR再ターゲティング時の管理者バイパスロジックを削除、関連ドキュメントを更新しました。

変更内容

Cohort / File(s) Summary
ドキュメント
\.github\/copilot-instructions\.md, README\.md
main→staging 同期ポリシー説明を「プッシュ後に自動で同期PRを作成/再利用する」旨へ更新。旧来の管理者例外や同期手順の記載を削除。
enforce-staging-flow スクリプト変更
\.github\/scripts\/enforce-staging-flow\.sh
ADMIN_BYPASS_CACHEauthor_has_admin_bypass を削除。gh api による collaborator-permission チェックと著者ベースの早期退出を除去し、TSV 列定義から author を削除して判定ロジックを簡素化。
同期スクリプト(新規)
\.github\/scripts\/sync-main-to-staging\.sh
新規実行可能スクリプトを追加。既存PR検出、compare API による ahead_by 判定、DRY_RUN、ラベル/アサイン/レビュワー処理を含む PR 作成ロジックを実装。環境変数で動作を制御。
同期ワークフロー(新規)
\.github\/workflows\/sync-main-to-staging\.yml
push(main) および workflow_dispatch トリガのワークフローを追加。open-sync-pr ジョブでリポジトリをチェックアウトして同期スクリプトを実行。コンカレンシーと必要パーミッションを設定。

Sequence Diagram(s)

sequenceDiagram
  participant Git as "Git (push)"
  participant GHWF as "GitHub Actions\n(sync-main-to-staging)"
  participant Script as "sync-main-to-staging.sh"
  participant GHAPI as "GitHub API\n(compare / pr / labels)"

  Git->>GHWF: push to main (or manual)
  GHWF->>Script: run script with env (GH_REPO, SYNC_SHA, ...)
  Script->>GHAPI: GET open PRs (search base=head)
  alt existing PR found
    GHAPI-->>Script: return PR URL
    Script-->>GHWF: log and exit
  else no existing PR
    Script->>GHAPI: GET compare base...head
    alt ahead_by == 0
      GHAPI-->>Script: ahead_by = 0
      Script-->>GHWF: log "nothing to sync" and exit
    else ahead_by > 0
      Script->>GHAPI: POST create PR (title, body)
      GHAPI-->>Script: return PR URL/number
      Script->>GHAPI: PATCH add labels / assignees / reviewers
      Script-->>GHWF: log PR created
    end
  end
Loading

推定コードレビュー工数

🎯 4 (Complex) | ⏱️ ~45 minutes

関連する可能性のあるPR

🐰 変更の芽がぴょんと出たよ
mainからstagingへ道をつなぐよ
鎧はもう置いて、素直な流れで
小さなPRが跳ねる朝に
にんじん片手で祝杯をどうぞ

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive PR タイトル「Staging」は、PR #344 での staging → main の同期後にステージングブランチを main にプロモートするという主要な変更を意図していますが、極めて簡潔すぎて具体性に欠けています。 「Promote staging to main with staging-first enforcement and sync automation」のように、ステージングのプロモート、執行ルール追加、自動化の導入を明示したより具体的なタイトルの使用を検討してください。
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed PR 説明は staging のプロモート、staging-first 執行、main→staging 同期自動化、依存関係の更新など、変更内容に関連する詳細が記載されており、チェンジセットの目的が明確に説明されています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch staging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code labels Apr 7, 2026
@codspeed-hq

codspeed-hq Bot commented Apr 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks
⏩ 15 skipped benchmarks1


Comparing staging (e883925) with main (a491cf9)

Open in CodSpeed

Footnotes

  1. 15 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request automates the synchronization between the main and staging branches by introducing a new script, sync-main-to-staging.sh, which automatically creates or reuses a sync PR after pushes to main. Additionally, the enforce-staging-flow.sh script has been simplified by removing the admin bypass logic and author-related metadata. Documentation in README.md and .github/copilot-instructions.md has been updated to align with these workflow changes. I have no feedback to provide.

@codecov

codecov Bot commented Apr 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Comment thread .github/workflows/sync-main-to-staging.yml Outdated
Comment thread .github/scripts/sync-main-to-staging.sh Outdated
@coderabbitai coderabbitai Bot added the documentation Improvements or additions to documentation label Apr 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/scripts/sync-main-to-staging.sh:
- Around line 64-69: Update the gh pr create invocation to include desired
reviewers/assignees and labels so automated sync PRs are easier to triage: add
the --assignee (or --reviewer) flag with a default user or team and add one or
more --label flags (e.g., "sync","automated"), referencing the existing
variables used in the command (GH_REPO, BASE_BRANCH, HEAD_BRANCH, title, body)
and ensure any labels you add are created beforehand or create them in the
script prior to calling gh pr create.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a0cf83e0-93c9-44d5-99f7-231bdf70e1b1

📥 Commits

Reviewing files that changed from the base of the PR and between a491cf9 and 7b252e2.

📒 Files selected for processing (5)
  • .github/copilot-instructions.md
  • .github/scripts/enforce-staging-flow.sh
  • .github/scripts/sync-main-to-staging.sh
  • .github/workflows/sync-main-to-staging.yml
  • README.md

Comment thread .github/scripts/sync-main-to-staging.sh Outdated
Configure sync-main-to-staging automation to create or update labels before PR creation, and pass label/assignee/reviewer metadata to gh pr create via env-configurable values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ci(sync): add metadata for automated main->staging PRs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/sync-main-to-staging.yml:
- Around line 17-33: The workflow hardcodes the default assignee/reviewer value
"is0692vs" for the SYNC_PR_ASSIGNEES and SYNC_PR_REVIEWERS env vars in the
open-sync-pr job; change the defaults to rely on repository variables instead of
a specific username by removing or replacing the hardcoded 'is0692vs' fallback
so that SYNC_PR_ASSIGNEES and SYNC_PR_REVIEWERS use vars.SYNC_PR_ASSIGNEES and
vars.SYNC_PR_REVIEWERS (or an empty string) as the default in the job
environment, ensuring the script receives configurable values rather than a
single hardcoded user.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f136a25-3d05-4971-bf9d-8a4a849c70bd

📥 Commits

Reviewing files that changed from the base of the PR and between 7b252e2 and 6d42ba1.

📒 Files selected for processing (2)
  • .github/scripts/sync-main-to-staging.sh
  • .github/workflows/sync-main-to-staging.yml

Comment thread .github/workflows/sync-main-to-staging.yml
Use repository variables (or empty values) for SYNC_PR_ASSIGNEES and SYNC_PR_REVIEWERS so sync automation stays configurable and avoids a fixed username.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ci(sync): remove hardcoded assignee/reviewer fallback
@is0692vs
is0692vs merged commit 2af3e4d into main Apr 7, 2026
31 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant