Skip to content

Commit 024b8f7

Browse files
authored
Update Breakage.yml (#156)
* Update Breakage.yml * Apply suggestions from code review
1 parent f8058c1 commit 024b8f7

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

.github/workflows/Breakage.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,49 @@ jobs:
159159
fi
160160
done >> summary.md
161161
162+
- name: Display summary in CI logs
163+
run: |
164+
echo "### Breakage Summary" >> $GITHUB_STEP_SUMMARY
165+
cat breakage/summary.md >> $GITHUB_STEP_SUMMARY
166+
162167
- name: PR comment with file
163-
uses: thollander/actions-comment-pull-request@v3
168+
if: github.event.pull_request.head.repo.fork == false
169+
uses: actions/github-script@main
164170
with:
165-
filePath: breakage/summary.md
171+
github-token: ${{ secrets.GITHUB_TOKEN }}
172+
script: |
173+
// Import file content from summary.md
174+
const fs = require('fs')
175+
const filePath = 'breakage/summary.md'
176+
const msg = fs.readFileSync(filePath, 'utf8')
177+
178+
// Get the current PR number from context
179+
const prNumber = context.payload.pull_request.number
180+
181+
// Fetch existing comments on the PR
182+
const { data: comments } = await github.rest.issues.listComments({
183+
owner: context.repo.owner,
184+
repo: context.repo.repo,
185+
issue_number: prNumber
186+
})
187+
188+
// Find a previous comment by the bot to update
189+
const botComment = comments.find(comment => comment.user.id === 41898282)
190+
191+
if (botComment) {
192+
// Update the existing comment
193+
await github.rest.issues.updateComment({
194+
owner: context.repo.owner,
195+
repo: context.repo.repo,
196+
comment_id: botComment.id,
197+
body: msg
198+
})
199+
} else {
200+
// Create a new comment
201+
await github.rest.issues.createComment({
202+
owner: context.repo.owner,
203+
repo: context.repo.repo,
204+
issue_number: prNumber,
205+
body: msg
206+
})
207+
}

0 commit comments

Comments
 (0)