Comments PR with failed host build log
This commit is contained in:
parent
05c8786716
commit
80b8b61835
1 changed files with 49 additions and 0 deletions
|
|
@ -85,6 +85,9 @@ jobs:
|
|||
echo " $HOST: ${BUILD_TIMES[$HOST]}"
|
||||
done
|
||||
|
||||
# Save failed hosts for the comment step
|
||||
echo "$FAILED_HOSTS" > failed_hosts.txt
|
||||
|
||||
if [ -n "$FAILED_HOSTS" ]; then
|
||||
echo "Some builds failed"
|
||||
exit 1
|
||||
|
|
@ -99,6 +102,52 @@ jobs:
|
|||
path: build-*.txt
|
||||
retention-days: 7
|
||||
|
||||
- name: Comment on PR with build failures
|
||||
if: steps.build.outcome == 'failure'
|
||||
env:
|
||||
PR_TOKEN: ${{ secrets.PR_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [ ! -f failed_hosts.txt ]; then
|
||||
echo "No failed hosts file found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
FAILED_HOSTS=$(cat failed_hosts.txt)
|
||||
|
||||
# Build comment body
|
||||
{
|
||||
echo "## ❌ Build Failed"
|
||||
echo ""
|
||||
echo "The following hosts failed to build:"
|
||||
echo ""
|
||||
|
||||
for HOST in $FAILED_HOSTS; do
|
||||
LOG_FILE="build-${HOST}.txt"
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
echo "<details>"
|
||||
echo "<summary><b>${HOST}</b></summary>"
|
||||
echo ""
|
||||
echo '```'
|
||||
tail -n 150 "$LOG_FILE"
|
||||
echo '```'
|
||||
echo ""
|
||||
echo "</details>"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
} > comment_body.md
|
||||
|
||||
# Post comment to PR using jq for proper JSON escaping
|
||||
jq -Rs '{body: .}' comment_body.md > payload.json
|
||||
|
||||
curl -sf -X POST \
|
||||
-H "Authorization: token $PR_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @payload.json \
|
||||
"${{ forgejo.api_url }}/repos/${{ forgejo.repository }}/issues/${{ forgejo.event.pull_request.number }}/comments"
|
||||
|
||||
- name: Check build result
|
||||
run: |
|
||||
if [ "${{ steps.build.outcome }}" == "failure" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue