Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/weekly-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Weekly Release PR

on:
schedule:
# 週六 10:00 UTC+8 = 週六 02:00 UTC
- cron: "0 2 * * 6"
workflow_dispatch:

permissions:
contents: read
pull-requests: write

jobs:
create-release-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if develop is ahead of main
id: check
run: |
git fetch origin main develop
COMMITS_AHEAD=$(git rev-list --count origin/main..origin/develop)
echo "commits_ahead=$COMMITS_AHEAD" >> "$GITHUB_OUTPUT"
echo "develop is $COMMITS_AHEAD commits ahead of main"

- name: Skip if nothing to release
if: steps.check.outputs.commits_ahead == '0'
run: echo "develop is up to date with main, skipping."

# 以下 step 全由 if: 條件守衛,不依賴上方 skip step 的 exit 狀態
- name: Check for existing open release PR
if: steps.check.outputs.commits_ahead != '0'
id: existing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING=$(gh pr list --base main --head develop --state open --json number --jq '.[0].number')
echo "existing_pr=$EXISTING" >> "$GITHUB_OUTPUT"
if [ -n "$EXISTING" ]; then
echo "Release PR #$EXISTING already open, skipping."
fi

- name: Create release PR
if: steps.check.outputs.commits_ahead != '0' && steps.existing.outputs.existing_pr == ''
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DATE=$(TZ=Asia/Taipei date +%Y-%m-%d)
COMMITS_AHEAD=${{ steps.check.outputs.commits_ahead }}
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

- name: Dispatch CI against develop
if: steps.check.outputs.commits_ahead != '0' && steps.existing.outputs.existing_pr == ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run ci.yml --ref develop
2 changes: 1 addition & 1 deletion scripts/pr-metadata-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ main() {
fi

local depends_on_raw=""
depends_on_raw=$(grep -iE '^[[:space:]-]*Depends on PR[::][[:space:]]*' "$body_file" | head -n1 | sed -E 's/^[^::]*[::][[:space:]]*//' | sed 's/[[:space:]]*$//')
depends_on_raw=$(grep -iE '^[[:space:]-]*Depends on PR[::][[:space:]]*' "$body_file" | head -n1 | sed -E 's/^[^::]*[::][[:space:]]*//' | sed 's/[[:space:]]*$//' || true)

if [ "$is_infra_or_chore" -eq 0 ] && [ "$is_release_promotion" -eq 0 ]; then
grep -Eq '#[0-9]+' "$body_file" || failures+=("PR body 必須引用至少一個 issue 或 PR 編號,例如 #123")
Expand Down
Loading