Skip to content
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

Enhance error reporting with GitHub annotation groups #19

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Changes from all 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
11 changes: 7 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ runs:

MERGE_COMMITS=$(git log --merges --format=%H origin/${{github.base_ref}}..refs/remotes/pull/${{github.event.pull_request.number}}/merge^2 --)
if [ -n "$MERGE_COMMITS" ]; then
echo "::error title={Found merge commits}::Please refer to https://github.com/motlin/forbid-merge-commits-action#handling-failure-messages for guidance."
echo "Found merge commits:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "::error title=Found merge commits::Found merge commits. Refer to https://github.com/motlin/forbid-merge-commits-action#handling-failure-messages for guidance."
for COMMIT_HASH in $MERGE_COMMITS; do
echo "::error::Merge commit: $COMMIT_HASH"
echo "::warning::Merge commit: $COMMIT_HASH"
echo "- $COMMIT_HASH" >> $GITHUB_STEP_SUMMARY
echo "::group::git show $COMMIT_HASH"
echo "Merge commit found: $COMMIT_HASH" >> $GITHUB_STEP_SUMMARY
git show $COMMIT_HASH
echo "::endgroup::"
done
echo "For guidance on resolving merge commits, please refer to the handling failure messages section of the README.md: https://github.com/motlin/forbid-merge-commits-action#handling-failure-messages" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Refer to https://github.com/motlin/forbid-merge-commits-action#handling-failure-messages for guidance." >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "Success: No merge commits found"
Expand Down
Loading