Skip to content

Commit

Permalink
codeql comment test
Browse files Browse the repository at this point in the history
  • Loading branch information
DE7924 committed Dec 5, 2024
1 parent c588686 commit eb5592e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eb5592e

Please sign in to comment.