[chore] 自動化週發布:weekly-release-pr workflow - #366
Conversation
refs #365 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Scope Police
Snapshot
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 55 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/weekly-release-pr.yml (1)
49-66:⚠️ Potential issue | 🔴 CriticalCritical:YAML 區塊純量縮排錯誤,workflow 無法被解析
run: |是 YAML literal block scalar,所有屬於該腳本的行(包含空行內含內容的後續行)必須維持與第一行相同或更深的縮排。目前 line 56--body "## Weekly Release — $DATE之後的 line 58、60、62-65 全部從第 0 欄開始,YAML parser 會在 line 58 結束 block scalar 並把Auto-generated by weekly-release-pr workflow.當成新的 key 來解析,因此 actionlint / yamllint 都報could not find expected ':'。這代表這個 workflow 檔案根本無法載入,cron 也不會觸發。需要修正才能 merge。建議改用 heredoc 或先把 body 寫到檔案再帶入
--body-file,例如:♻️ 建議修法(heredoc + --body-file)
- name: Create release PR if: steps.check.outputs.commits_ahead != '0' && steps.existing.outputs.existing_pr == '' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | DATE=$(TZ=Asia/Taipei date +%Y-%m-%d) COMMITS_AHEAD=${{ steps.check.outputs.commits_ahead }} - gh pr create \ - --base main \ - --head develop \ - --title "[release] develop → main ($DATE)" \ - --body "## Weekly Release — $DATE - - Auto-generated by weekly-release-pr workflow. - - **Commits ahead:** $COMMITS_AHEAD - - ### Checklist - - [ ] CI 通過 - - [ ] 確認無 half-finished feature - - [ ] Merge" + cat > /tmp/release-pr-body.md <<EOF + ## Weekly Release — $DATE + + Auto-generated by weekly-release-pr workflow. + + **Commits ahead:** $COMMITS_AHEAD + + ### Checklist + - [ ] CI 通過 + - [ ] 確認無 half-finished feature + - [ ] Merge + EOF + gh pr create \ + --base main \ + --head develop \ + --title "[release] develop → main ($DATE)" \ + --body-file /tmp/release-pr-body.md🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/weekly-release-pr.yml around lines 49 - 66, The YAML script block under run: | is incorrectly dedented causing the literal block scalar to end early; fix by either indenting every line of the shell script (including the multi-line PR body) to match the run: | block or replace the inline multi-line --body with a heredoc/temporary file approach: build the BODY using DATE and COMMITS_AHEAD, write it to a temp file (e.g., /tmp/pr_body.txt) and pass it to gh pr create with --body-file, ensuring the gh pr create invocation (and variables DATE and COMMITS_AHEAD) remain inside the properly indented run block.
🧹 Nitpick comments (2)
.github/workflows/weekly-release-pr.yml (2)
39-43: Minor:gh pr list --jq '.[0].number'在無結果時為空字串,行為正確但建議補註當沒有現有 open release PR 時,
.[0].number會輸出空字串,使existing_pr=''並讓後續Create release PR的steps.existing.outputs.existing_pr == ''判斷成立,邏輯沒問題。只是未來若有人改--jq表達式(例如改成.[0]或length)可能會默默壞掉,建議在這個 step 加一行註解說明「空字串 = 無現有 PR」。僅供參考。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/weekly-release-pr.yml around lines 39 - 43, Add a short inline comment in the workflow step around the EXISTING assignment (the gh pr list --jq '.[0].number' call and the existing_pr output) clarifying that an empty string indicates "no existing open release PR" so future changes to the --jq expression won't silently change behavior; reference the EXISTING variable, the gh pr list command, and steps.existing.outputs.existing_pr in the comment.
29-31: Minor:此 step 只是印 log,並沒有真的「skip」後續步驟
Skip if nothing to release只在commits_ahead == '0'時印訊息,後面Check for existing open release PR與Create release PR各自再用if:控制是否執行,行為上是正確的,只是 step 名稱容易讓人誤以為它會中止後續流程。可以考慮把名字改成Log: develop is up to date或乾脆把它合併進 check step 的 echo,讓閱讀 workflow 的人不會誤判控制流。僅供參考,非阻擋項。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/weekly-release-pr.yml around lines 29 - 31, The step named "Skip if nothing to release" is only printing a message and does not actually halt the workflow; rename the step to a clearer label like "Log: develop is up to date" or merge its echo into the prior check step to avoid misleading readers; update the step name referenced as "Skip if nothing to release" (and adjust any documentation) and ensure "Check for existing open release PR" and "Create release PR" remain controlled by their own if: conditions.
🤖 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/weekly-release-pr.yml:
- Around line 56-65: Update the multiline --body string used to create the PR
(the --body "## Weekly Release — $DATE ... $COMMITS_AHEAD" template) to include
the required scope/CI fields: add "Source of truth:`...`" (or "Source of
truth:"), "Depends on PR:none" (or a PR number), a "本 PR 明確不做" section, and a
"Backend contract already in develop" checklist with the "yes" box pre-checked;
keep the existing DATE and COMMITS_AHEAD variables and checklist items but
expand the body to match the suggested template so the [release] PR passes the
validations enforced by the CI and pr-scope-police workflows.
- Around line 45-52: The workflow currently injects the default GitHub Actions
token via GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}, which prevents other workflows
(CI/scope-police) from being triggered by the PR created with gh pr create;
replace the token injection with a project Personal Access Token or GitHub App
token stored in a secret (e.g., GH_PAT or GH_APP_TOKEN) and use that secret as
GH_TOKEN for the gh pr create step, or add an authentication step to mint a
GitHub App token (e.g., actions/create-github-app-token) and export it to
GH_TOKEN before running gh pr create; if you intend to keep using the default
behavior, explicitly document in the PR description/README that automated
release PRs will not trigger downstream workflows.
---
Outside diff comments:
In @.github/workflows/weekly-release-pr.yml:
- Around line 49-66: The YAML script block under run: | is incorrectly dedented
causing the literal block scalar to end early; fix by either indenting every
line of the shell script (including the multi-line PR body) to match the run: |
block or replace the inline multi-line --body with a heredoc/temporary file
approach: build the BODY using DATE and COMMITS_AHEAD, write it to a temp file
(e.g., /tmp/pr_body.txt) and pass it to gh pr create with --body-file, ensuring
the gh pr create invocation (and variables DATE and COMMITS_AHEAD) remain inside
the properly indented run block.
---
Nitpick comments:
In @.github/workflows/weekly-release-pr.yml:
- Around line 39-43: Add a short inline comment in the workflow step around the
EXISTING assignment (the gh pr list --jq '.[0].number' call and the existing_pr
output) clarifying that an empty string indicates "no existing open release PR"
so future changes to the --jq expression won't silently change behavior;
reference the EXISTING variable, the gh pr list command, and
steps.existing.outputs.existing_pr in the comment.
- Around line 29-31: The step named "Skip if nothing to release" is only
printing a message and does not actually halt the workflow; rename the step to a
clearer label like "Log: develop is up to date" or merge its echo into the prior
check step to avoid misleading readers; update the step name referenced as "Skip
if nothing to release" (and adjust any documentation) and ensure "Check for
existing open release PR" and "Create release PR" remain controlled by their own
if: conditions.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: de2e9ffe-93c7-46e3-a2b3-bee427a4b7b3
📒 Files selected for processing (1)
.github/workflows/weekly-release-pr.yml
…-pr workflow - Fix 1: Replace multiline --body with heredoc to resolve YAML indentation error - Fix 2: Add clarifying comment for skip logic guard conditions refs #366 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
refs #366 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
refs #366 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
♻️ Duplicate comments (2)
.github/workflows/weekly-release-pr.yml (2)
53-64:⚠️ Potential issue | 🔴 CriticalCritical:PR body 仍缺少 scope-gate 必要欄位,自動建立的 release PR 會被 CI 直接擋下(需要修正才能 merge)
依
.github/workflows/ci.ymlscope-gate 的releaseBodyValid判斷(見 relevant snippet L112-129),release PR body 必須同時包含:
Source of truth:或Source of truth:Depends on PR:後接none或#<num>- 字串
本 PR 明確不做Backend contract already in develop:區塊內勾選- [x] yes(且不能同時勾選 no)目前 L53-64 的 body 模板只有「Auto-generated / Commits ahead / 3 項 checklist」,上述 4 個必要欄位全部缺失,因此
releaseBodyValid=false→run_ci=false,每一個自動週發布 PR 都會卡在 scope-gate 無法 merge,違反本 PR「自動週發布」目標。另外scripts/pr-metadata-check.sh(L206-221)雖只驗證 title prefix 對 release promotion 的對應關係,這部份目前是符合的,但 body 的 scope-gate 驗證還是會擋。♻️ 建議補齊 body 模板
cat > /tmp/release-pr-body.md <<EOF ## Weekly Release — $DATE Auto-generated by weekly-release-pr workflow. **Commits ahead:** $COMMITS_AHEAD +## Scope 對齊 +- Source of truth:#365 +- Depends on PR:none +- Backend contract already in develop: + - [x] yes + - [ ] no + +## 本 PR 明確不做 +- 不做 hotfix +- 不調整 CI / workflow +- 不引入新的對外通知 + ### Checklist - [ ] CI 通過 - [ ] 確認無 half-finished feature - [ ] Merge EOF🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/weekly-release-pr.yml around lines 53 - 64, The generated release PR body is missing the scope-gate required fields checked by releaseBodyValid in ci.yml, so update the /tmp/release-pr-body.md template generation (the here-doc block using $DATE and $COMMITS_AHEAD) to include: a "Source of truth:" (accept both full-width and ASCII colon), a "Depends on PR:" line followed by "none" or "#<num>", the literal phrase "本 PR 明確不做", and a "Backend contract already in develop:" checklist with "- [x] yes" (and ensure "- [ ] no" is not checked); keep existing checklist items and title/commit info intact and validate against scripts/pr-metadata-check.sh expectations.
71-75:⚠️ Potential issue | 🟠 MajorMajor:
gh workflow run ci.yml --ref develop不會把 check 掛到自動建立的 release PR 上這個 step 看起來是想補償「
GITHUB_TOKEN建立的 PR 不會觸發 workflow」的限制,但實際上--ref develop會以workflow_dispatch在 develop branch 上跑一個獨立的 run,這個 run 不會出現在 release PR 的 checks 區,也不會被 branch protection(要求 CI 在 PR 上 pass 才能 merge 進 main)認可。結果:
- develop 那邊多跑一次(其實平常 push 已經會跑),對 release PR 本身沒幫助。
- release PR 仍維持 0 個 check,需要人類手動 close/reopen 或 push 一個 commit 觸發。
若要根治,建議改用 GitHub App token(例如
actions/create-github-app-token)或 PAT 注入GH_TOKEN後再gh pr create,這樣建立 PR 時就會正常觸發pull_requestevent 的 CI。或者在 PR description / README 明示「自動 release PR 需要手動 close/reopen 一次以觸發 CI」當作已知 workaround,並把這個Dispatch CI against developstep 移除(避免誤導維運者以為 CI 已經跑在 PR 上)。另:此 step 依賴
ci.yml已宣告workflow_dispatch:trigger,請確認。#!/bin/bash # 確認 ci.yml 是否支援 workflow_dispatch trigger fd -t f 'ci.yml' .github/workflows | xargs -I{} sh -c 'echo "=== {} ==="; sed -n "1,30p" {}"' rg -n -C2 'workflow_dispatch' .github/workflows/ci.yml🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/weekly-release-pr.yml around lines 71 - 75, The "Dispatch CI against develop" step uses gh workflow run ci.yml --ref develop which does not attach checks to the auto-created release PR; remove this step and instead obtain a GitHub App token or PAT (e.g., use actions/create-github-app-token or inject a PAT into GH_TOKEN) and call gh pr create (or recreate the PR with that token) so the workflow triggers via the pull_request event and appears on the PR checks; also verify ci.yml declares workflow_dispatch if you still intend to use workflow dispatch in any workflow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/weekly-release-pr.yml:
- Around line 53-64: The generated release PR body is missing the scope-gate
required fields checked by releaseBodyValid in ci.yml, so update the
/tmp/release-pr-body.md template generation (the here-doc block using $DATE and
$COMMITS_AHEAD) to include: a "Source of truth:" (accept both full-width and
ASCII colon), a "Depends on PR:" line followed by "none" or "#<num>", the
literal phrase "本 PR 明確不做", and a "Backend contract already in develop:"
checklist with "- [x] yes" (and ensure "- [ ] no" is not checked); keep existing
checklist items and title/commit info intact and validate against
scripts/pr-metadata-check.sh expectations.
- Around line 71-75: The "Dispatch CI against develop" step uses gh workflow run
ci.yml --ref develop which does not attach checks to the auto-created release
PR; remove this step and instead obtain a GitHub App token or PAT (e.g., use
actions/create-github-app-token or inject a PAT into GH_TOKEN) and call gh pr
create (or recreate the PR with that token) so the workflow triggers via the
pull_request event and appears on the PR checks; also verify ci.yml declares
workflow_dispatch if you still intend to use workflow dispatch in any workflow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 921d6243-bbd0-4b44-a404-25e4689f7201
📒 Files selected for processing (2)
.github/workflows/weekly-release-pr.ymlscripts/pr-metadata-check.sh
…mplate refs #366 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
本次 push 修正摘要Fix 1:Release PR body 補齊 scope police 必要欄位(Critical)自動產生的 body 新增:
另將 section header 從 Fix 2:pr-metadata-check.sh 的
|
Claude Code 審查結論:✅ 可 merge,無 blockerBlockers無。 Majors(不擋 merge,建議開 follow-up issue)
Minors
Nits
確認項目
|
refs #366 Co-Authored-By: Codex <codex[bot]@openai.com>
There was a problem hiding this comment.
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/weekly-release-pr.yml:
- Around line 41-48: The existing gh/jq pipeline sets EXISTING to the literal
"null" when no PR exists (because jq '.[0].number' yields null -> "null"),
causing steps.existing.outputs.existing_pr to be non-empty and skipping PR
creation; fix by changing the jq expression used in the gh pr list assignment to
coalesce null to an empty string (use jq's alternative/operator to return empty
when .[0].number is null) so that EXISTING is truly empty when no PR exists and
the conditional (steps.existing.outputs.existing_pr == '') behaves correctly.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 43a985c4-512d-46ad-86f9-f84393192da2
📒 Files selected for processing (1)
.github/workflows/weekly-release-pr.yml
refs #366 Co-Authored-By: Codex <codex[bot]@openai.com>
|
已處理這個 conversation:
本機驗證:
@coderabbitai resolve conversation |
|
Tip For best results, initiate chat on the files or code changes.
[resolve] 🧠 Learnings used |
背景
develop → main 的 release PR 需要人工手動開,容易忘記或延誤。
專案主力開發時間為平日晚上與週末,在週六早上自動開好 release PR,
讓開發者可以在週末有充裕時間 review 並 merge。
變更
.github/workflows/weekly-release-pr.yml0 2 * * 6(週六 10:00 UTC+8)workflow_dispatch手動觸發[release] develop → main (YYYY-MM-DD)完成條件
workflow_dispatch手動觸發正確開出 release PR本 PR 明確不做
closes #365
🤖 Generated with Claude Code
Summary by CodeRabbit
发布说明
新功能
改进