Move auto-merge comments to separate job for reliable failure reporting#4379
Conversation
Co-authored-by: wicksipedia <600044+wicksipedia@users.noreply.github.com>
|
|
||
| - name: Comment merge failure | ||
| uses: mshick/add-pr-comment@v2 | ||
| if: steps.auto-merge-pr.outcome == 'failure' |
There was a problem hiding this comment.
@copilot I want this to run even if there is a failure in an earlier step. maybe the 2 actions should be a separate job? that way if any of the steps in the job fail it can be a catch all
There was a problem hiding this comment.
Done! I've moved the comment steps to a separate comment-result job that:
- Always runs with
if: always()(when is-small-change is true) - Acts as a catch-all for any failures in the auto-merge job
- Uses
needs.auto-merge.resultto determine success vs failure
This ensures the failure comment will post even if the auto-merge job encounters an exception that marks it as failed.
Changes in commit 6a1c86d
Co-authored-by: wicksipedia <600044+wicksipedia@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR restructures the auto-merge workflow to improve reliability of status reporting by moving comment steps into a separate job that always runs, even when the merge operation fails with an exception.
Key changes:
- Created a new
comment-resultjob that runs independently usingif: always()to ensure execution regardless of the auto-merge job's outcome - Split the single conditional comment step into two separate steps based on success/failure status
- Separated the informational message ("This PR was automatically merged...") to only appear in success scenarios
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| - name: Comment merge failure | ||
| uses: mshick/add-pr-comment@v2 | ||
| if: needs.auto-merge.result == 'failure' |
There was a problem hiding this comment.
The failure comment condition only checks for failure status, but the auto-merge job could also have cancelled or skipped statuses. Consider handling these additional states to ensure users receive feedback in all non-success scenarios.
Suggested condition:
if: needs.auto-merge.result != 'success'This would catch failure, cancelled, and skipped states, providing feedback whenever the merge doesn't complete successfully.
| if: needs.auto-merge.result == 'failure' | |
| if: needs.auto-merge.result != 'success' |
Restructured the auto-merge workflow to ensure comments are posted reliably in all scenarios, including when the merge step fails with an exception.
Changes:
comment-resultjob that runs separately from theauto-mergejobif: always()to ensure it runs even when the auto-merge job failsneeds.auto-merge.result:Comment merge success- Runs only when merge succeeds, includes "This PR was automatically merged as a small content change."Comment merge failure- Runs only when merge fails, shows error message onlyBefore:
After:
Benefits:
Failure comments now post even if the auto-merge job encounters an exception
Better separation of concerns between merging and status reporting
More reliable feedback to PR authors in all scenarios
Affected routes: N/A (workflow change only)
If adding a new page, I have followed the 📃 New Webpage issue template
If updating the livestream banner, I have tested and followed the steps in Wiki - Testing the live banner
Include Done Video or screenshots
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.