diff --git a/.github/scripts/comment.js b/.github/scripts/comment.js index 1bc8ea035c..429a34d3a0 100644 --- a/.github/scripts/comment.js +++ b/.github/scripts/comment.js @@ -2,10 +2,13 @@ module.exports = async ({ github, context, header, body }) => { const comment = [header, body].join("\n"); + const pr_number = await get_pr_number(github, context); + console.log(pr_number()); + const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: context.payload.number, + issue_number: pr_number, }); const botComment = comments.find( @@ -25,3 +28,20 @@ module.exports = async ({ github, context, header, body }) => { : { issue_number: context.payload.number }), }); }; + +// Returns gh PR number +async function get_pr_number(github, context) { + if (context.issue.number) { + // Return issue number if present + return context.issue.number; + } else { + // Otherwise return issue number from commit + return ( + await github.rest.repos.listPullRequestsAssociatedWithCommit({ + commit_sha: context.sha, + owner: context.repo.owner, + repo: context.repo.repo, + }) + ).data[0].number; + } +} \ No newline at end of file diff --git a/.github/workflows/slither.yml b/.github/workflows/slither.yml index 997b794b8b..b82abcb822 100644 --- a/.github/workflows/slither.yml +++ b/.github/workflows/slither.yml @@ -16,21 +16,23 @@ jobs: id: slither with: fail-on: none - continue-on-error: true sarif: results.sarif slither-config: ethereum-bridge-contracts/slither.config.json target: ethereum-bridge-contracts slither-args: --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/ - - name: ls - run: ls + - name: Push SARIF to DefectDojo + # TODO: push to DefectDojo + run: ls results.sarif - name: Create/update checklist as PR comment uses: actions/github-script@v6 if: github.event_name == 'push' + env: + REPORT: ${{ steps.slither.outputs.stdout }} with: script: | const script = require('.github/scripts/comment') const header = '# Slither report' -# const body = `${{ steps.slither.outputs.stdout }}` -# await script({ github, context, header, body }) + const { REPORT } = process.env + await script({ github, context, header, body: REPORT })