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

fix(updateComment): fix update comment failed when action was run manually #19

Closed
wants to merge 4 commits into from
Closed
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
24 changes: 22 additions & 2 deletions .github/workflows/ecosystem-ci-from-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ jobs:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
result-encoding: string
script: |
const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
Expand Down Expand Up @@ -231,11 +232,30 @@ jobs:
}).join("\n")}
`

await github.rest.issues.deleteComment({
// delete previous comment and create a new one when run by manually
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: 'core',
comment_id: ${{ needs.init.outputs.comment-id }}
issue_number: context.payload.inputs.prNumber
})
console.log(comments)
const lastComment = comments.reverse().find(comment =>
comment.body.includes('Ran ecosystem CI:')
)
console.log(lastComment)
if (lastComment) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: 'core',
comment_id: lastComment.id
})
} else {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: 'core',
comment_id: ${{ needs.init.outputs.comment-id }}
})
}

await github.rest.issues.createComment({
issue_number: context.payload.inputs.prNumber,
Expand Down