From eb5592e61ae711e2ff3d6793ce63413150c1d36b Mon Sep 17 00:00:00 2001 From: Daniel Eshkeri Date: Thu, 5 Dec 2024 09:09:57 +0000 Subject: [PATCH] codeql comment test --- .github/workflows/codeql.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/pull-request.yml | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7b5379d6..985eb371 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,6 +31,43 @@ jobs: with: languages: ${{ matrix.language }} - name: Perform CodeQL Analysis + id: perform-codeql-analysis uses: github/codeql-action/analyze@v2 with: category: "/language:${{matrix.language}}" + - name: Post failure comment + if: always() + # if: failure() + uses: actions/github-script@v6 + with: + script: | + const conclusion = ${{ steps.perform-codeql-analysis.conclusion }}; + const outcome = ${{ steps.perform-codeql-analysis.outcome }}; + const sarif = ${{ steps.perform-codeql-analysis.outputs.sarif-output }}; + const commentBody = ` + ## CodeQL Analysis + ${conclusion} + ${outcome} + ${sarif} + `; + const { data: comments } = await github.rest.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo + }); + const comment = comments.find(comment => comment.body.includes('CodeQL Analysis')); + if (comment) { + await github.rest.issues.updateComment({ + comment_id: comment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + } else { + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + } diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1dd3dd8c..650a55b9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -149,7 +149,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo }); - const comment = comments.find(comment => comment.body.includes('Code Quality Checks Failed')); + const comment = comments.find(comment => comment.body.includes('Code Quality Checks')); if (comment) { await github.rest.issues.updateComment({ comment_id: comment.id,