-
Notifications
You must be signed in to change notification settings - Fork 0
[chore] 自動化週發布:weekly-release-pr workflow #366
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 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
842ab9f
chore: add weekly release PR workflow(週六 10:00 UTC+8 自動觸發)
Erick52106 64c1e78
fix: resolve YAML indentation and skip logic issues in weekly-release…
Erick52106 604b93f
chore: dispatch CI against develop after release PR creation
Erick52106 3acd202
fix(scripts): guard depends_on_raw grep against set -e exit on no-match
Erick52106 8d64502
fix(workflow): add required scope police fields to release PR body te…
Erick52106 63ea5fc
fix: correct weekly release workflow permissions and yaml
Erick52106 1204b40
fix: make release PR lookup fallback explicit
Erick52106 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
Some comments aren't visible on the classic Files Changed page.
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
| 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 == '' | ||
| 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 | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.