diff --git a/.github/workflows/gen-killed-in-gaza.yml b/.github/workflows/gen-killed-in-gaza.yml index 31f1f8b7..cc4bcba6 100644 --- a/.github/workflows/gen-killed-in-gaza.yml +++ b/.github/workflows/gen-killed-in-gaza.yml @@ -68,10 +68,10 @@ jobs: run: | # if our log output has lines there's issues worth noting if [[ $(wc -l > "" >> "$GITHUB_OUTPUT" + echo "logs=1" >> "$GITHUB_OUTPUT" fi if [[ $(wc -l > "" >> "$GITHUB_OUTPUT" + echo "diff=1" >> "$GITHUB_OUTPUT" fi - uses: actions/github-script@v7 @@ -104,9 +104,31 @@ jobs: body += '- [ ] a diff of the JSON file changes for review\n' } - github.rest.issues.createComment({ + const commonInputs = { issue_number: process.env.PRNUM, owner: context.repo.owner, - repo: context.repo.repo, + repo: context.repo.repo + } + + // delete prior comments + const comments = await github.rest.issues.listComments(commonInputs) + const idsToDelete = comments + .filter(comment => comment.user.login.includes('github-action')) + .map(comment => comment.id) + + console.log(`found ${idsToDelete.length} comments to delete: ${idsToDelete.join(',')}`) + + if (idsToDelete.length) { + await idsToDelete.reduce(async (chain, comment_id) => { + await chain; + await github.rest.issues.deleteComment({ + ...commonInputs, + comment_id + }) + }, Promise.resolve()) + } + + await github.rest.issues.createComment({ + ...commonInputs, body })