Skip to content

Commit 831b132

Browse files
committed
Add comments to PR
1 parent d8e58e4 commit 831b132

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/check-links.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,69 @@ jobs:
7575
runs-on: ubuntu-latest
7676
steps:
7777
- name: Create Summary
78+
id: create-summary
7879
run: |-
7980
echo "# Documentation Link Check Results" >> $GITHUB_STEP_SUMMARY
8081
8182
# Initialize FAILED variable
8283
FAILED=false
8384
85+
# Create summary content for PR comment
86+
COMMENT_BODY="## Documentation Link Check Results\n\n"
87+
8488
# Check for failures in absolute links job
8589
if [[ "${{ needs.check-absolute-links.outputs.exit_code }}" != "0" ]]; then
8690
echo "❌ **Absolute links check failed**" >> $GITHUB_STEP_SUMMARY
8791
echo "There are broken absolute links in the documentation. Please check the job logs for details." >> $GITHUB_STEP_SUMMARY
92+
COMMENT_BODY+="❌ **Absolute links check failed**\n\nThere are broken absolute links in the documentation. [See workflow logs for details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n"
8893
FAILED=true
8994
else
9095
echo "✅ **Absolute links check passed**" >> $GITHUB_STEP_SUMMARY
96+
COMMENT_BODY+="✅ **Absolute links check passed**\n\n"
9197
fi
9298
9399
# Check for failures in relative links job
94100
if [[ "${{ needs.check-relative-links.outputs.exit_code }}" != "0" ]]; then
95101
echo "❌ **Relative links check failed**" >> $GITHUB_STEP_SUMMARY
96102
echo "There are broken relative links in the documentation. Please check the job logs for details." >> $GITHUB_STEP_SUMMARY
103+
COMMENT_BODY+="❌ **Relative links check failed**\n\nThere are broken relative links in the documentation. [See workflow logs for details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n"
97104
FAILED=true
98105
else
99106
echo "✅ **Relative links check passed**" >> $GITHUB_STEP_SUMMARY
107+
COMMENT_BODY+="✅ **Relative links check passed**\n\n"
100108
fi
101109
110+
# Add timestamp
111+
COMMENT_BODY+="\n\n<sub>Last checked: $(date -u '+%Y-%m-%d %H:%M:%S UTC')</sub>"
112+
113+
# Save comment body to output
114+
echo "comment_body<<EOF" >> $GITHUB_OUTPUT
115+
echo "$COMMENT_BODY" >> $GITHUB_OUTPUT
116+
echo "EOF" >> $GITHUB_OUTPUT
117+
118+
# Save failed status to output
119+
echo "failed=$FAILED" >> $GITHUB_OUTPUT
120+
102121
# Exit with failure if any checks failed
103122
if [[ "$FAILED" == "true" ]]; then
104123
echo "::error::One or more link checks failed. Please fix the broken links."
105124
exit 1
106125
fi
126+
127+
- name: Find Comment
128+
uses: peter-evans/find-comment@v2
129+
if: github.event_name == 'pull_request'
130+
id: find-comment
131+
with:
132+
issue-number: ${{ github.event.pull_request.number }}
133+
comment-author: "github-actions[bot]"
134+
body-includes: "Documentation Link Check Results"
135+
136+
- name: Create or Update Comment
137+
uses: peter-evans/create-or-update-comment@v2
138+
if: github.event_name == 'pull_request'
139+
with:
140+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
141+
issue-number: ${{ github.event.pull_request.number }}
142+
body: ${{ steps.create-summary.outputs.comment_body }}
143+
edit-mode: replace

0 commit comments

Comments
 (0)