Repository navigation
feat: auto-merge update PRs and stagger maintenance schedules - #82
Conversation
|
| if [ "$AUTO_MERGE" = "true" ] && [ "$DRY_RUN" != "true" ]; then | ||
| # The branch (and PR) is reused across runs; only enable auto-merge | ||
| # if it is not already enabled, since re-enabling it errors. | ||
| if [ "$(gh pr view "$BRANCH" --json autoMergeRequest --jq '.autoMergeRequest')" = "null" ]; then |
There was a problem hiding this comment.
Failed lookup looks successful
If gh pr view fails, its empty output makes this comparison false. The step then finishes successfully without enabling auto-merge, leaving the PR waiting for manual action. Capture the result separately and stop on a failed lookup before checking autoMergeRequest.
| if [ "$(gh pr view "$BRANCH" --json autoMergeRequest --jq '.autoMergeRequest')" = "null" ]; then | |
| AUTO_MERGE_REQUEST=$(gh pr view "$BRANCH" --json autoMergeRequest --jq '.autoMergeRequest') || exit $? | |
| if [ "$AUTO_MERGE_REQUEST" = "null" ]; then |
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Approve and enable auto-merge for patch and minor updates | ||
| if: steps.meta.outputs.update-type != 'version-update:semver-major' |
There was a problem hiding this comment.
Unknown updates pass the filter
This condition accepts every update-type except the exact major-update value, including an empty or unfamiliar value. That could enable auto-merge without confirming the update is patch or minor. Explicitly allow those two values so unknown metadata leaves the PR for review.
| if: steps.meta.outputs.update-type != 'version-update:semver-major' | |
| if: steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor' |
| if [ "$AUTO_MERGE" = "true" ] && [ "$DRY_RUN" != "true" ]; then | ||
| # The branch (and PR) is reused across runs; only enable auto-merge | ||
| # if it is not already enabled, since re-enabling it errors. | ||
| if [ "$(gh pr view "$BRANCH" --json autoMergeRequest --jq '.autoMergeRequest')" = "null" ]; then | ||
| gh pr merge "$BRANCH" --auto --squash --delete-branch | ||
| fi |
There was a problem hiding this comment.
Neither new auto-merge path has test coverage. Both action tests use dry-run, and the existing PR helper tests never run these commands. Mistakes in when poetry-lock-update or pre-commit-autoupdate merges PRs can therefore pass unnoticed. Add tests with a fake gh for opt-in merging, dry-run and disabled inputs, an already-enabled PR, and lookup failures.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The GitHub App authors these PRs and cannot approve its own PR, so auto-merge never satisfied the required review. Approve with the workflow token (a different actor) before enabling auto-merge. Extract the approve-and-merge logic into a shared actions/common/auto_merge.sh and address Greptile review findings: - fail the step when the auto-merge lookup errors instead of silently skipping the merge - match patch/minor Dependabot update types explicitly so unknown metadata is left for review - add tests covering opt-in, dry-run, disabled, already-enabled, missing app token, and lookup-failure paths
Summary
auto-mergeinput topre-commit-autoupdateandpoetry-lock-updatethat enables squash auto-merge on the PRs they open, and enable it in this repo's workflows.dependabot-auto-mergeworkflow that approves and enables auto-merge for patch/minor Dependabot updates.Notes
dependabot/fetch-metadatais hash-pinned to satisfy zizmor'sunpinned-usespolicy.