diff --git a/.github/workflows/ecosystem-ci-from-pr.yml b/.github/workflows/ecosystem-ci-from-pr.yml index c4b3b66..1aa5675 100644 --- a/.github/workflows/ecosystem-ci-from-pr.yml +++ b/.github/workflows/ecosystem-ci-from-pr.yml @@ -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, @@ -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,