feat: enable auto-merge for dependency update PRs#22
Conversation
Add an auto-merge step to the dependency-update workflow that automatically merges the PR when both tests and format checks pass.
There was a problem hiding this comment.
Pull request overview
Updates the reusable dependency update workflow to automatically enable auto-merge for the generated dependency-update PR when the workflow’s test and format steps succeed.
Changes:
- Adds a step
idto the PR-creation step so downstream steps can use its outputs. - Adds a GitHub CLI step to enable PR auto-merge when tests and formatting pass.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| - name: Enable auto-merge | ||
| if: >- | ||
| steps.create_pr.outputs.pull-request-number && | ||
| steps.test_run.outcome == 'success' && | ||
| steps.format_check.outcome == 'success' |
| - name: Enable auto-merge | ||
| if: >- | ||
| steps.create_pr.outputs.pull-request-number && | ||
| steps.test_run.outcome == 'success' && | ||
| steps.format_check.outcome == 'success' |
| - name: Enable auto-merge | ||
| if: >- | ||
| steps.create_pr.outputs.pull-request-number && | ||
| steps.test_run.outcome == 'success' && | ||
| steps.format_check.outcome == 'success' |
- Add auto-merge input parameter (default: true) for opt-in control - Add continue-on-error to prevent workflow failure when auto-merge is not available on the repository - Update PR body to reflect auto-merge status instead of misleading manual review instructions
Copilot レビュー対応3件の指摘に対応しました (b68efff) 1. auto-merge 未対応リポジトリでの失敗防止
2. opt-in 制御
3. PR本文の矛盾解消
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so dependency bump PRs can be automatically queued for merging when tests and formatting succeed.
Changes:
- Introduces a new
auto-mergeworkflow input to control whether auto-merge is attempted. - Adds a post-PR-creation step that runs
gh pr merge --auto --mergewhen tests/format pass. - Updates the PR body to include an auto-merge status line.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| type: number | ||
| auto-merge: | ||
| description: 'Enable auto-merge when tests and format pass' | ||
| default: true |
| - [ ] All tests pass | ||
| - [ ] No breaking changes in dependencies | ||
| - [ ] Security advisories addressed (if any) | ||
| - Auto-merge: ${{ inputs.auto-merge && steps.test_run.outcome == 'success' && steps.format_check.outcome == 'success' && 'enabled' || 'disabled (manual review required)' }} |
- Change auto-merge default to false (opt-in) to prevent unexpected behavior in downstream repos upgrading to this version - Change PR body text from 'enabled' to 'requested' to reflect that auto-merge may not succeed - Add warning step when auto-merge fails to alert about missing repo settings - Update usage comment with auto-merge example
Copilot レビュー対応 (2回目)2件の指摘に対応しました (035e452) 1. auto-merge デフォルトを false に変更 (opt-in 化)
2. PR本文と実際の状態の不整合を解消
呼び出し側の対応(マージ後に必要)各リポジトリの jobs:
dependency-update:
uses: smkwlab/.github/.github/workflows/dependency-update.yml@v1
with:
auto-merge: true
secrets: inherit |
There was a problem hiding this comment.
Pull request overview
Updates the reusable “Dependency Update” GitHub Actions workflow to optionally request GitHub auto-merge for dependency update PRs when the workflow’s test and format steps succeed.
Changes:
- Adds a new
auto-mergeworkflow_callinput (defaultfalse) and documents its usage. - Captures the PR number from
peter-evans/create-pull-requestand conditionally runsgh pr merge --autoto enable auto-merge. - Updates the generated PR body to include an “Auto-merge” status line.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| - [ ] All tests pass | ||
| - [ ] No breaking changes in dependencies | ||
| - [ ] Security advisories addressed (if any) | ||
| - Auto-merge: ${{ inputs.auto-merge && steps.test_run.outcome == 'success' && steps.format_check.outcome == 'success' && 'requested' || 'disabled (manual review required)' }} |
| run: | | ||
| echo "Enabling auto-merge for PR #${{ steps.create_pr.outputs.pull-request-number }}" | ||
| gh pr merge ${{ steps.create_pr.outputs.pull-request-number }} \ | ||
| --auto --merge |
Copilot レビュー対応 (3回目)2件の指摘に対応しました (ff12bce) 1. Auto-merge 状態メッセージの改善PR本文の Auto-merge 表示を3つの状態に分類:
2. マージ方式の設定可能化
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so dependency bump PRs can be merged automatically when checks pass.
Changes:
- Introduces
auto-mergeandmerge-methodinputs to control auto-merge behavior. - Captures the created PR number and runs
gh pr merge --autowhen tests/format succeed. - Updates the generated PR body to include auto-merge status.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| auto-merge: | ||
| description: 'Enable auto-merge when tests and format pass (requires allow_auto_merge repo setting)' | ||
| default: false | ||
| required: false | ||
| type: boolean | ||
| merge-method: | ||
| description: 'Merge method for auto-merge (merge, squash, or rebase)' | ||
| default: 'merge' | ||
| required: false | ||
| type: string |
| run: | | ||
| echo "Enabling auto-merge for PR #${{ steps.create_pr.outputs.pull-request-number }}" | ||
| gh pr merge ${{ steps.create_pr.outputs.pull-request-number }} \ | ||
| --auto --${{ inputs.merge-method }} | ||
|
|
| run: | | ||
| echo "Enabling auto-merge for PR #${{ steps.create_pr.outputs.pull-request-number }}" | ||
| gh pr merge ${{ steps.create_pr.outputs.pull-request-number }} \ | ||
| --auto --${{ inputs.merge-method }} |
…-branch #22 - Rename auto-merge/merge-method to auto_merge/merge_method to avoid hyphen being interpreted as subtraction in GitHub Actions expressions - Add merge method validation step to whitelist merge/squash/rebase and prevent shell injection - Add --delete-branch flag to gh pr merge to clean up branches after auto-merge
Copilot レビュー対応 (4回目)3件の指摘に対応しました (7b411c9) 1. ハイフン付きinput名のリネーム
2. merge method のバリデーション追加
3.
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so dependency-update PRs can be automatically merged once tests/format succeed.
Changes:
- Introduces
auto_mergeandmerge_methodinputs for the reusable workflow. - Adds merge-method validation and a
gh pr merge --autostep to request auto-merge after successful checks. - Updates the created PR body to include an “Auto-merge” status line.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| auto_merge: | ||
| description: 'Enable auto-merge when tests and format pass (requires allow_auto_merge repo setting)' | ||
| default: false | ||
| required: false | ||
| type: boolean | ||
| merge_method: | ||
| description: 'Merge method for auto-merge (merge, squash, or rebase)' | ||
| default: 'merge' | ||
| required: false | ||
| type: string |
| required: false | ||
| type: number | ||
| auto_merge: | ||
| description: 'Enable auto-merge when tests and format pass (requires allow_auto_merge repo setting)' |
| - [ ] All tests pass | ||
| - [ ] No breaking changes in dependencies | ||
| - [ ] Security advisories addressed (if any) | ||
| - Auto-merge: ${{ !inputs.auto_merge && 'disabled' || (steps.test_run.outcome != 'success' || steps.format_check.outcome != 'success') && 'skipped (checks failed)' || 'requested' }} |
| - name: Warn if auto-merge failed | ||
| if: steps.auto_merge.outcome == 'failure' | ||
| run: | | ||
| echo "::warning::Auto-merge could not be enabled. Check that 'Allow auto-merge' is enabled in repository settings." |
- Add comment explaining why auto_merge/merge_method use snake_case (hyphens interpreted as subtraction in if: expressions) - Fix description to reference actual UI setting name "Allow auto-merge" in repo Settings > General - Change PR body auto-merge status to "pending" instead of "requested" to avoid implying success before the step runs - Add PR comment step to confirm actual auto-merge result (success or failure with detailed error output and troubleshooting guide) - Use env vars instead of direct expression interpolation in shell commands for safer execution
Copilot レビュー対応 (5回目)4件の指摘に対応しました (0adb13d) 1. snake_case の命名理由を明記
2. description の表現を修正
3. PR本文の auto-merge 表示を改善
4. 詳細なエラーフィードバック
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so dependency PRs can be automatically merged when formatting and tests pass.
Changes:
- Adds
auto_mergeandmerge_methodinputs for controlling auto-merge behavior. - Captures PR creation output and attempts to enable auto-merge via
gh pr merge --autowhen checks pass. - Updates the generated PR body to include auto-merge status.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| # NOTE: snake_case is intentional for auto_merge and merge_method. | ||
| # Hyphens in input names are interpreted as subtraction in GitHub Actions | ||
| # `if:` expressions (e.g., inputs.auto-merge → inputs.auto minus merge). | ||
| auto_merge: |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ steps.create_pr.outputs.pull-request-number }} | ||
| MERGE_METHOD: ${{ steps.validate_merge.outputs.method }} | ||
| run: | |
| - \"Allow auto-merge\" is not enabled in repository Settings > General | ||
| - The merge method (${MERGE_METHOD:-merge}) is not allowed by repository settings | ||
| - Insufficient token permissions | ||
| - Branch protection rules are blocking auto-merge | ||
|
|
||
| **Error output:** | ||
| \`\`\` | ||
| ${ERROR_OUTPUT} | ||
| \`\`\` |
| - name: Update PR on auto-merge result | ||
| if: steps.auto_merge.outcome == 'success' || steps.auto_merge.outcome == 'failure' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ steps.create_pr.outputs.pull-request-number }} | ||
| run: | | ||
| if [ "${{ steps.auto_merge.outcome }}" = "success" ]; then | ||
| gh pr comment "${PR_NUMBER}" --body "Auto-merge has been enabled successfully." | ||
| else | ||
| ERROR_OUTPUT=$(cat /tmp/auto-merge-output.txt 2>/dev/null || echo "unknown error") | ||
| gh pr comment "${PR_NUMBER}" --body "$(cat <<EOFCOMMENT | ||
| ⚠️ Auto-merge could not be enabled. | ||
|
|
||
| **Possible causes:** | ||
| - \"Allow auto-merge\" is not enabled in repository Settings > General | ||
| - The merge method (${MERGE_METHOD:-merge}) is not allowed by repository settings | ||
| - Insufficient token permissions |
- Clarify snake_case comment: explain that kebab-case inputs are safe in with:/interpolation contexts, only if: expressions need snake_case - Add set -o pipefail so gh pr merge failures are not masked by tee - Replace unquoted heredoc with string concatenation to avoid backslash escaping issues in PR comments - Add MERGE_METHOD env var to the result reporting step
Copilot レビュー対応 (6回目)4件の指摘に対応しました (f5a6d21) 1. snake_case コメントの矛盾を解消
2. pipefail の追加
3. heredoc エスケープの修正
4. MERGE_METHOD env var の追加
|
There was a problem hiding this comment.
Pull request overview
This PR enhances the reusable dependency update workflow by adding optional auto-merge support for the dependency update PRs it creates.
Changes:
- Add new
workflow_callinputsauto_mergeandmerge_method(snake_case) to control auto-merge behavior. - Capture the created PR number and, when enabled and checks pass, attempt to enable GitHub auto-merge via
gh pr merge --auto. - Update the example usage snippet and PR body to include auto-merge status information.
Comments suppressed due to low confidence (1)
.github/workflows/dependency-update.yml:126
- Auto-merge may never complete in repositories that rely on PR-required status checks: this workflow creates/updates the PR using
secrets.GITHUB_TOKEN, and GitHub does not trigger other workflows from events caused byGITHUB_TOKEN(e.g., the branch push/PR creation). In that case,gh pr merge --autowill remain pending because the required checks never run on the PR. Consider accepting an optional caller-provided PAT (viaworkflow_call.secrets) and using it for checkout/create-pull-request andGH_TOKEN, or explicitly documenting that auto-merge requires a non-GITHUB_TOKENtoken in the calling workflow.
- name: Create Pull Request
id: create_pr
if: steps.check_changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update dependencies"
title: "chore: weekly dependency update"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| - [ ] All tests pass | ||
| - [ ] No breaking changes in dependencies | ||
| - [ ] Security advisories addressed (if any) | ||
| - Auto-merge: ${{ !inputs.auto_merge && 'disabled' || (steps.test_run.outcome != 'success' || steps.format_check.outcome != 'success') && 'skipped (checks failed)' || 'pending (will be confirmed by workflow)' }} |
| - name: Enable auto-merge | ||
| id: auto_merge | ||
| if: steps.validate_merge.outcome == 'success' | ||
| continue-on-error: true |
…-error #22 - Move auto-merge status calculation from inline expression to dedicated step for readability and maintainability - Add comment explaining why continue-on-error is intentional: PR creation is the primary goal, auto-merge failure is reported via PR comment rather than failing the workflow
Copilot レビュー対応 (7回目)2件の指摘に対応しました (f4c7cc9) 1. Auto-merge ステータスの式を分離
2. continue-on-error の意図を明記
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so dependency update PRs can be automatically merged when checks pass.
Changes:
- Add new
workflow_callinputsauto_mergeandmerge_methodto control whether/How dependency update PRs auto-merge. - Add steps to validate the merge method, enable GitHub auto-merge via
gh pr merge --auto, and comment on the PR with the result. - Update the PR body to include an “Auto-merge” status line.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| inputs.auto_merge && | ||
| steps.create_pr.outputs.pull-request-number && | ||
| steps.test_run.outcome == 'success' && | ||
| steps.format_check.outcome == 'success' |
Copilot レビュー対応 (8回目)1件の指摘に対応しました (a037175) 1. ハイフン付き output 名のブラケット記法
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so dependency bump PRs can be automatically merged once tests and formatting pass.
Changes:
- Introduces
auto_mergeandmerge_methodinputs for enabling/configuring auto-merge. - Adds steps to validate merge method, enable auto-merge via
gh, and comment on the PR with the outcome. - Updates the PR body to include an “Auto-merge” status line.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| - name: Determine auto-merge status | ||
| id: auto_merge_status | ||
| if: steps.check_changes.outputs.changes == 'true' | ||
| run: | | ||
| if [ "${{ inputs.auto_merge }}" != "true" ]; then | ||
| echo "label=disabled" >> "$GITHUB_OUTPUT" | ||
| elif [ "${{ steps.test_run.outcome }}" != "success" ] || [ "${{ steps.format_check.outcome }}" != "success" ]; then | ||
| echo "label=skipped (checks failed)" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "label=pending (will be confirmed by workflow)" >> "$GITHUB_OUTPUT" | ||
| fi |
| - name: Validate merge method | ||
| id: validate_merge | ||
| if: >- | ||
| inputs.auto_merge && | ||
| steps.create_pr.outputs['pull-request-number'] && | ||
| steps.test_run.outcome == 'success' && | ||
| steps.format_check.outcome == 'success' |
- Move validate_merge step before create_pr so invalid merge_method is detected before PR is created - Add "skipped (invalid merge method)" status to auto_merge_status - Enable auto-merge step now checks validate_merge.outcome along with PR number and test results
Copilot レビュー対応 (9回目)2件の指摘に対応しました (c0b08fd) 1. merge_method バリデーションをPR作成前に移動ステップの実行順序を変更:
2. 無効な merge_method のステータス表示
|
There was a problem hiding this comment.
Pull request overview
Adds optional auto-merge support to the reusable dependency update workflow so that dependency bump PRs can be merged automatically when checks pass.
Changes:
- Introduces
auto_mergeandmerge_methodworkflow-call inputs to control auto-merge behavior. - Adds steps to validate merge method, surface auto-merge status in the PR body, and enable auto-merge via
gh pr merge --auto. - Posts a PR comment indicating whether auto-merge was enabled successfully (or why it failed).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| - name: Validate merge method | ||
| id: validate_merge | ||
| if: inputs.auto_merge | ||
| run: | | ||
| case "${{ inputs.merge_method }}" in | ||
| merge|squash|rebase) | ||
| echo "method=${{ inputs.merge_method }}" >> "$GITHUB_OUTPUT" | ||
| ;; | ||
| *) | ||
| echo "::error::Invalid merge method: ${{ inputs.merge_method }}. Must be merge, squash, or rebase." | ||
| exit 1 | ||
| ;; |
| # These inputs are used in `if:` expressions where hyphens are parsed | ||
| # as the subtraction operator (e.g., inputs.auto-merge → inputs.auto minus merge). | ||
| # The existing kebab-case inputs (otp-version, etc.) are only used in | ||
| # `with:` / `${{ }}` string interpolation contexts where hyphens are safe. |
Copilot レビュー対応 (10回目)2件の指摘に対応しました (06699da) 1. validate_merge に continue-on-error 追加
2. snake_case NOTE を簡素化
|
There was a problem hiding this comment.
Pull request overview
Adds opt-in auto-merge support to the reusable dependency update workflow so that dependency update PRs can be automatically merged when tests/format checks succeed.
Changes:
- Introduces
auto_merge(boolean) andmerge_method(string) inputs for the reusable workflow. - Adds validation and status reporting for auto-merge, surfacing the result in the PR body and via a PR comment on failure.
- Enables auto-merge via
gh pr merge --autowhen preconditions are met.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR extends the reusable dependency-update workflow to optionally enable GitHub auto-merge for the generated dependency update PR when checks pass.
Changes:
- Adds
auto_mergeandmerge_methodworkflow-call inputs to control auto-merge behavior. - Implements merge-method validation and conditional
gh pr merge --autoexecution. - Updates the created PR body to include auto-merge status and posts a follow-up PR comment on auto-merge failure.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| # NOTE: snake_case is intentional for auto_merge and merge_method | ||
| # because they are used in `if:` expressions where hyphens would be | ||
| # parsed as the subtraction operator. |
Summary
peter-evans/create-pull-requestの出力からPR番号を取得してgh pr merge --auto --mergeを実行前提条件(設定済み)
allow_auto_mergeを有効化済みci / Code Qualityを required status check として追加済み対象リポジトリ
Test plan